Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _03._Inbox_Manager
- {
- class Program
- {
- static void Main(string[] args)
- {
- var emails = new Dictionary<string, List<string>>();
- string cmd = Console.ReadLine();
- while (cmd != "Statistics")
- {
- string[] cmdArgs = cmd.Split("->");
- string cmdT = cmdArgs[0];
- if (cmdT == "Add")
- {
- string user = cmdArgs[1];
- if (emails.ContainsKey(user))
- {
- Console.WriteLine($"{user} is already registered");
- }
- else
- {
- emails.Add(user, new List<string>());
- }
- }
- else if (cmdT == "Send")
- {
- string user = cmdArgs[1];
- string mail = cmdArgs[2];
- emails[user].Add(mail);
- }
- else if (cmdT == "Delete")
- {
- string user = cmdArgs[1];
- if (emails.ContainsKey(user))
- {
- emails.Remove(user);
- }
- else
- {
- Console.WriteLine($"{user} not found!");
- }
- }
- cmd = Console.ReadLine();
- }
- Console.WriteLine($"Users count: {emails.Count}");
- foreach (var userMail in emails.OrderByDescending(mail => mail.Value.Count).ThenBy(name => name.Key))
- {
- Console.WriteLine(userMail.Key);
- Console.WriteLine(string.Join("\n - ", userMail.Value));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement