Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.InteropServices.ComTypes;
- namespace _3.Followers
- {
- class Program
- {
- static void Main(string[] args)
- {
- var record = new Dictionary<string, Dictionary<string, int>>();
- string input = String.Empty;
- while ((input = Console.ReadLine()) != "Log out")
- {
- string[] data = input.Split(": ");
- string command = data[0];
- if (command.Contains("New follower"))
- {
- string username = data[1];
- if (!record.ContainsKey(username))
- {
- record.Add(username, new Dictionary<string, int>()
- {
- {"likes", 0 },
- {"comments", 0 }
- }
- );
- }
- }
- else if (command.Contains("Like"))
- {
- string username = data[1];
- int count = int.Parse(data[2]);
- if (!record.ContainsKey(username))
- {
- record.Add(username, new Dictionary<string, int>()
- {
- {"likes", count },
- {"comments", 0 }
- });
- }
- else
- {
- record[username]["likes"] += count;
- record[username]["comments"] += 0;
- }
- }
- else if (command.Contains("Comment"))
- {
- string username = data[1];
- if (!record.ContainsKey(username))
- {
- record.Add(username, new Dictionary<string, int>()
- {
- {"likes", 0},
- {"coments", 1}
- }) ;
- }
- else
- {
- record[username]["likes"] += 0;
- record[username]["comments"]++;
- }
- }
- else if (command.Contains("Blocked"))
- {
- string username = data[1];
- if (!record.ContainsKey(username))
- {
- Console.WriteLine($"{username} doesn't exist");
- }
- else
- {
- record.Remove(username);
- }
- }
- }
- Console.WriteLine($"{record.Keys.Count} followers");
- foreach (var user in record.OrderByDescending(x => x.Value["likes"]).ThenBy(x => x.Key))
- {
- var sum = user.Value["likes"] + user.Value["comments"];
- Console.WriteLine($"{user.Key}: {sum}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement