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.Text.RegularExpressions;
- using System.Xml;
- namespace ConsoleApp8
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- Dictionary<string,int[]> users = new Dictionary<string, int[]>();
- while (input != "Log out" )
- {
- string[] splitted = input.Split(": ");
- string command = splitted[0];
- string username = splitted[1];
- if (command == "New follower")
- {
- if (!users.ContainsKey(username))
- {
- users.Add(username,new int[2]);
- }
- }
- else if (command == "Like")
- {
- int likes = int.Parse(splitted[2]);
- if (!users.ContainsKey(username))
- {
- users.Add(username,new int[2]{likes,0});
- }
- else
- {
- users[username][0] += likes;
- }
- }
- else if (command == "Comment")
- {
- if (!users.ContainsKey(username))
- {
- users.Add(username,new int[2]{0,1});
- }
- else
- {
- users[username][1]++;
- }
- }
- else if (command == "Blocked")
- {
- if (!users.ContainsKey(username))
- {
- Console.WriteLine("{Username} doesn't exist.");
- }
- else
- {
- users.Remove(username);
- }
- }
- input = Console.ReadLine();
- }
- Console.WriteLine($"{users.Count} followers");
- foreach (var user in users.OrderByDescending(x=>x.Value[0]).ThenBy(x=>x.Key))
- {
- Console.WriteLine($"{user.Key}: {user.Value[0] + user.Value[1]}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement