In a social network, a person can invite friends of
his/her friend. John wants to invite and add new friends. Complete the program
below so that it prints the names of the persons to whom John can send a friend
request.
Input Format: The first line contains the value of the N which
represent the number of friends. Next N lines contain the name of the friend F
followed by the number of friends of F and finally their names separated by
space.
Boundary Conditions: 2 <= N <= 10
Output Format: The names to
which John can send a friend request.
Example Input/Output 1:
Input:
3
Mani 3
Ram Raj Guna
Ram 2 Kumar Kishore
Mughil 3 Praveen Naveen Ramesh
Output:
Raj
Guna Kumar Kishore Praveen Naveen Ramesh
Explanation: Ram is not present in the
output as Ram is already John's friend.
Example Input/Output 2:
Input:
4
Arjun
3 Bhuvana Ramya Rajesh
Naveen 2 Arjun Sangeetha
Rajesh 3 Narmada Madan Suresh
Suresh 2 Pawan Adhil
Output:
Bhuvana Ramya Sangeetha Narmada Madan Pawan Adhil
Source Code:
#include<stdio.h>
int main()
{
int n,t,i,j=0,k,f;
char a[100][100],b[100][100];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s
%d",a[i],&t);
while(t--)
scanf("%s",b[j++]);
}
for(i=0;i<j;i++)
{
f=0;
for(k=0;k<n;k++)
{
if(strcmp(a[k],b[i])==0)
f=1;
}
if(f==0)
printf("%s ",b[i]);
}
}
The importance of social networking sites in today's world is immense. Indeed, the above mentioned websites are best, however there is also a latest Social Networking site MyworldGo , where you can connect with others. We are also available on iOS and android.
ReplyDeletecan u please send me the whole program please...my mail is manasisudhirpatil@gmail.com
ReplyDeletecan u please send me the whole program please...my mail is manasisudhirpatil@gmail.com
ReplyDelete