Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _1._3_FollowersOtherSolution
- {
- class Program
- {
- static void Main()
- {
- Dictionary<string, int> followersAndLikes = new Dictionary<string, int>();
- Dictionary<string, int> followersAndComments = new Dictionary<string, int>();
- string commands = Console.ReadLine();
- while (commands != "Log out")
- {
- string[] commandsArgs = commands.Split(": ");
- string command = commandsArgs[0];
- string username = commandsArgs[1];
- switch (command)
- {
- case "New follower":
- if (!followersAndLikes.ContainsKey(username))
- {
- followersAndLikes.Add(username, 0);
- followersAndComments.Add(username, 0);
- }
- break;
- case "Like":
- int count = int.Parse(commandsArgs[2]);
- if (!followersAndLikes.ContainsKey(username))
- {
- followersAndLikes.Add(username, 0);
- followersAndComments.Add(username, 0);
- }
- followersAndLikes[username] += count;
- break;
- case "Comment":
- if (!followersAndComments.ContainsKey(username))
- {
- followersAndLikes.Add(username, 0);
- followersAndComments.Add(username, 0);
- }
- followersAndComments[username]++;
- break;
- case "Blocked":
- if (followersAndLikes.ContainsKey(username))
- {
- followersAndLikes.Remove(username);
- followersAndComments.Remove(username);
- }
- else
- {
- Console.WriteLine($"{username} doesn't exist.");
- }
- break;
- }
- commands = Console.ReadLine();
- }
- Console.WriteLine($"{followersAndComments.Count} followers");
- foreach (var kvp in followersAndLikes
- .OrderByDescending(u => u.Value)
- .ThenBy(u => u.Key))
- {
- int likesAndComments = kvp.Value + followersAndComments[kvp.Key];
- Console.WriteLine($"{kvp.Key}: {likesAndComments}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement