Advertisement
Guest User

football

a guest
Mar 24th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Football
  6. {
  7. class Program
  8. {
  9. static void Main()
  10. {
  11. Dictionary<string, int> dict = new Dictionary<string, int>();
  12.  
  13. while (true)
  14. {
  15. string input = Console.ReadLine();
  16.  
  17. if (input == "End of season")
  18. {
  19. break;
  20. }
  21.  
  22. string[] playerArgs = input.Split(" - ");
  23.  
  24. string name = playerArgs[0];
  25. int goals = int.Parse(playerArgs[1]);
  26.  
  27. if (dict.ContainsKey(name) == false)
  28. {
  29. dict[name] = 0;
  30. }
  31. dict[name] += goals;
  32. }
  33.  
  34. foreach (var player in dict.OrderBy(x => x.Key).ThenBy(g => g.Value))
  35. {
  36. Console.WriteLine($"{player.Key} -> {player.Value}");
  37. }
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement