Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Inbox_Manager
- {
- class Program
- {
- static void Main(string[] args)
- {
- var userName= new Dictionary<string, List<String>>();
- var usermsg= new Dictionary<string, List<String>>();
- int userCount = 0;
- string[] comand = Console.ReadLine().Split("->").ToArray();
- while (comand[0] != "Statistics")
- {
- if (comand[0]=="Add")
- {
- string name=comand[1];
- if (userName.ContainsKey(name))
- {
- Console.WriteLine($"{name} is already registered");//ako go ima
- }
- else if (!userName.ContainsKey(name))///ako ne sadarja KEY
- {
- userName[name] = new List<string>();//syzdavame KEY
- userCount += 1;//BROIM KEY
- }
- userName[name].Add(name);
- }
- else if (comand[0] == "Send")
- {
- string name = comand[1];
- string email = comand[2];
- if (userName.ContainsKey(name))
- {
- if (!usermsg.ContainsKey(name))
- {
- usermsg[name] = new List<string>();
- }
- usermsg[name].Add(email);
- }
- }
- else if (comand[0] == "Delete")
- {
- string name = comand[1];
- if (userName.ContainsKey(name))//ako sydarja key
- {
- userName.Remove(name);//triene na KEY
- usermsg.Remove(name);
- userCount--;//namalqme broq4a
- }
- else
- {
- Console.WriteLine($"{name} not found!");
- }
- }
- comand = Console.ReadLine().Split("->").ToArray();
- }
- Console.WriteLine($"Users count: {userCount}");//userName.Keys.Count
- //Console.WriteLine($"Users count: {userName.Keys.Count}");
- usermsg = usermsg.OrderByDescending(x => x.Value.Count).ThenBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value);
- foreach (var item in usermsg)
- {
- Console.WriteLine($"{item.Key}");
- Console.WriteLine($" - {string.Join(Environment.NewLine + " - ",item.Value)}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement