Advertisement
desislava_topuzakova

4.

Apr 10th, 2022
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace _04.PassStatistics
  5. {
  6. internal class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. SortedDictionary<string, int> passesDict = new SortedDictionary<string, int>();
  11.  
  12. string command = Console.ReadLine();
  13.  
  14. while (command != "End of match")
  15. {
  16. string[] arrayPlayer = command.Split(" - ");
  17. string name = arrayPlayer[0];
  18. int passes = int.Parse(arrayPlayer[1]);
  19.  
  20. if (!passesDict.ContainsKey(name))
  21. {
  22. passesDict[name] = passes;
  23. }
  24. else
  25. {
  26. int newCount = passesDict[name] + passes;
  27. passesDict[name] = newCount;
  28. }
  29. command = Console.ReadLine();
  30.  
  31. }
  32.  
  33.  
  34. foreach (var entry in passesDict)
  35. {
  36. Console.WriteLine($"{entry.Key} has passed {entry.Value} passes.");
  37. }
  38. }
  39. }
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement