• Make Order

  • order processing

  • Approve and Get
    your Order
Order Now

Add, remove, list friends

C program that can be able to add a friend ship, remove a friendship, and print out the friend(s) for a particular user. You can assume that friendships go both ways, i.e. if A is friends with B, then B is also friends with A.
Input:
The input will begin with an integer q (q 500,000), number of queries to your webpage. The next q lines will each contain 1 server query. There are 3 query types. The first query type is the add query. The add query will begin with the word ADD followed by two names, a and b. The word ADD and the names will all be separated by a single space. This query implies the people named a and b have become friends. The second query is the remove query. The remove query
will begin with the word REMOVE followed by two names, a and b. The word REMOVE and the two names will be separated by a single space. The remove query will denote that user a and b are no longer friends. The last query type is the list query. The list query will begin with the word LIST followed by one name, a, representing the user we wish to list the friends of. Each name will be at most 100 lower case characters and will contain no whitespace. No user will become a friend of themselves. No user will remove themselves as a friend. If a friendship is added, it will be between two users that are currently not friends. If a friendship is removed, it will be between two users that are currently friends.
Output:
For each list query print out on a line by itself the number of friends the user has. After which print out the names of each friend of the given user (in any order) each on their own line.

You can leave a response, or trackback from your own site.
Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes