desislava_topuzakova

4. Football Season

Apr 9th, 2022
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace _03._Word_Game
  5. {
  6. internal class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. string score = Console.ReadLine();
  11. SortedDictionary<string, int> scorers = new SortedDictionary<string, int>();
  12. while (score != "End of season")
  13. {
  14. string [] arrayScorers = score.Split(" - ");
  15. string name = arrayScorers[0];
  16. int goals = int.Parse(arrayScorers[1]);
  17.  
  18. if (!scorers.ContainsKey(name))
  19. {
  20. scorers.Add(name, goals);
  21. }
  22. else
  23. {
  24. int newScore = scorers[name] + goals;
  25. scorers.Add(name, newScore);
  26. }
  27. score = Console.ReadLine();
  28.  
  29. }
  30.  
  31.  
  32. }
  33. }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment