Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApp15
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. var users = new Dictionary<string, string>();
  13. string input = null;
  14. while (input != "Statistics")
  15. {
  16. input = Console.ReadLine();
  17. string[] cmd = input.Split("->");
  18. string command = cmd[0];
  19. //string username = cmd[1];
  20. if (command == "Add")
  21. {
  22.  
  23. if (!users.ContainsKey(cmd[1]))
  24. {
  25. users.Add(cmd[1], " ");
  26. }
  27. else
  28. {
  29. Console.WriteLine($"{cmd[1]} is already registered");
  30. }
  31. }
  32. if (command == "Send")
  33. {
  34.  
  35. users[cmd[1]] += cmd[2];
  36. //users[cmd[1]].Add(cmd[2]);
  37. //users[cmd[1]].Add(cmd[2]);
  38. }
  39. if (command == "Delete")
  40. {
  41. if (users.ContainsKey(cmd[1]))
  42. {
  43. users.Remove(cmd[1]);
  44. }
  45. else
  46. {
  47. Console.WriteLine($"{cmd[1]} not found!");
  48. }
  49. }
  50. }
  51. //foreach (var kvpLikes in users.OrderByDescending(u => u.Value).ThenBy(u => u.Key))
  52. //{
  53. // Console.WriteLine($"{kvpLikes.Key}: {kvpLikes.Value + users[kvpLikes.Key]} ");
  54. ////}
  55. foreach (var user in users.OrderBy(u => u.Value).ThenByDescending(u => u.Key))
  56. {
  57. Console.Write($"{user.Key}: ");
  58. Console.WriteLine();
  59.  
  60. Console.WriteLine($"- {user.Value} ");
  61.  
  62.  
  63.  
  64. }
  65. //foreach (var item in users.OrderBy(x => x.Key))
  66. //{
  67. // Console.Write($"{item.Key}");
  68. // foreach (string shit in item.Value)
  69. // {
  70. // Console.WriteLine($"{shit} ");
  71. // }
  72.  
  73. //}
  74. }
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement