Advertisement
Guest User

Untitled

a guest
Oct 30th, 2019
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. namespace Fallowers
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. Dictionary<string, List<int>> users = new Dictionary<string, List<int>>();
  11.  
  12. while (true)
  13. {
  14. string command = Console.ReadLine();
  15. if (command== "Log out")
  16. {
  17. break;
  18. }
  19. string[] tokens = command.Split(':').ToArray();
  20. string name = tokens[1];
  21. if (tokens[0]== "New follower")
  22. {
  23. if (!users.ContainsKey(name))
  24. {
  25. users.Add(name, new List<int>());
  26. users[name].Add(0);
  27. users[name].Add(0);
  28. }
  29.  
  30. }
  31. else if (tokens[0] == "Like")
  32. {
  33. if (!users.ContainsKey(name))
  34. {
  35. users.Add(name, new List<int>());
  36. users[name].Add(0);
  37. users[name].Add(0);
  38. users[name][0] += int.Parse(tokens[2]);
  39. }
  40. else
  41. {
  42. users[name][0] += int.Parse(tokens[2]);
  43. }
  44. }
  45. else if (tokens[0] == "Comment")
  46. {
  47. if (!users.ContainsKey(name))
  48. {
  49. users.Add(name, new List<int>());
  50. users[name].Add(0);
  51. users[name].Add(0);
  52. users[name][1] += 1;
  53. }
  54. else
  55. {
  56. users[name][1] += 1;
  57. }
  58. }
  59. else if (tokens[0] == "Blocked")
  60. {
  61. if (!users.ContainsKey(name))
  62. {
  63. Console.WriteLine($"{name} doesn't exist.");
  64. }
  65. else
  66. {
  67. users.Remove(name);
  68. }
  69. }
  70. }
  71. Console.WriteLine($"{users.Count} followers");
  72. users.OrderBy(n => n.Key).ThenByDescending(v=>v.Value.Sum());
  73.  
  74. foreach (var name in users.Keys)
  75. {
  76. int total = users[name][0] += users[name][1];
  77. foreach (var list in users[name])
  78. {
  79.  
  80. Console.WriteLine($"{name}: {total}");
  81. }
  82. }
  83.  
  84. }
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement