Thursday 18 May 2017

Social Networking Link List using C

Influenced by Social Networking sites, James launches his own site SocialNet. Each user in SocialNet is given a unique number, first user being numbered 1. There are N users in SocialNet numbered from 1 to N. In SocialNet, there is a two-way link as in Facebook. James wants to print the friend list of each user. If the any use does not have friends, then print 0. Help James to do so.

Input:

The first line of input takes the number of users, N. The second line takes the no of connections in the SocialNet. The remaining lines are the connection from one user to another.

Output:

Print all friends list of all the users.

Sample Input 1: Enter the no. of users: 3

Enter the no. of connections: 2 Enter the start node and end node in the connection 1:

1 2

Enter the start node and end node in the connection 2:

2 3

Sample Output 1:

The friends list of all users:

1->2

2->1 3

3->2



via roxy angurala

No comments:

Post a Comment