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