Friday, 22 January 2021

class 11 th program of java for the data of party date of friends

import java.io.*;
class party
{
    public static void main(String args[])throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
       System.out.println("enter the number of friends ");
         int n=Integer.parseInt(br.readLine());
         int i,j;
         int free[][]=new int[n][31];
         if(n>1)
         {
         for(i=0;i<n;i++)
         {
             System.out.println("enter the freeb date of friend="+(i+1));
             for(j=0;j<31;j++)
             {
                 free[i][j]=Integer.parseInt(br.readLine());
                 if(free[i][j]==0)
                 {
                     break;
                    }}} int arr1[]=new int[31];int x=0;
       for(i=0;i<31;i++)
       {int temp=free[0][i];int c=0;
           for(j=1;j<n;j++)
           {
                  for(int k=0;k<31;k++)
                  {
                      if(temp==free[j][k]&&temp!=0)
                      {
                         c=c+1;
                        }
                    }
                    if(c==(n-1))
                    { 
                       arr1[x]=temp;x++;
                }               
                
            }
        }
        if(x>2)
        {System.out.print("Suitable date for party is ");
            for(i=0;i<x-2;i++)
            {
                System.out.print(arr1[i]+",");
            }
            System.out.print(arr1[x-1]+"and"+arr1[x-2]);
        }
    else if(x==2)
{
    System.out.print("Suitable date for party is ");
    System.out.print(arr1[0]+"and"+arr1[1]);
}
else
{
System.out.print("suitable date for party is "+arr1[0]);}}
else{
    System.out.println("he may be always free on such date");
}
}}
    

No comments:

Post a Comment

HAY THAKYOU FOE VISIT

Program(python):-Find duplicates in an array (Geeks for geek problem)

QUESTION:- Given an array  a  of size  N  which contains elements from  0  to  N-1 , you need to find all the elements occurring more than o...