Advertisement
ss3434

Untitled

Mar 9th, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Inbox_Manager
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. var userName= new Dictionary<string, List<String>>();
  12.  
  13. int userCount = 0;
  14. string[] comand = Console.ReadLine().Split("->").ToArray();
  15. while (comand[0] != "Statistics")
  16. {
  17. if (comand[0]=="Add")
  18. {
  19. string name=comand[1];
  20. if (userName.ContainsKey(name))//ako ne sadarja KEY
  21. {
  22. Console.WriteLine($"{name} is already registered");//ako go ima
  23. }
  24. else if (!userName.ContainsKey(name))
  25. {
  26. userName[name] = new List<string>();//syzdavame KEY
  27.  
  28. userCount += 1;//BROIM KEY
  29.  
  30. }
  31.  
  32. }
  33. else if (comand[0] == "Send")
  34. {
  35. string name = comand[1];
  36. string email = comand[2];
  37. if (userName.ContainsKey(name))
  38. {
  39. userName[name].Add(email);
  40.  
  41. }
  42. }
  43. else if (comand[0] == "Delete")
  44. {
  45. string name = comand[1];
  46. if (userName.ContainsKey(name))//ako sydarja key
  47. {
  48. userName.Remove(name);//triene na KEY
  49.  
  50. userCount--;//namalqme broq4a
  51. }
  52. else
  53. {
  54. Console.WriteLine($"{name} not found!");
  55. }
  56.  
  57. }
  58. comand = Console.ReadLine().Split("->").ToArray();
  59. }
  60.  
  61. Console.WriteLine($"Users count: {userCount}");//userName.Keys.Count
  62. //Console.WriteLine($"Users count: {userName.Keys.Count}");
  63.  
  64. userName = userName.OrderByDescending(x => x.Value.Count).ThenBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value);
  65. foreach (var item in userName)
  66. {
  67. Console.WriteLine($"{item.Key}");
  68. Console.WriteLine($" - {string.Join(Environment.NewLine + " - ",item.Value)}");
  69. }
  70. }
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement