Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _04.FootballSeason
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. // string players = "";
  14. Dictionary<string, int> goals = new Dictionary<string, int>();
  15. do
  16. {
  17. // players = Console.ReadLine();
  18. //split input
  19. string[] token = Console.ReadLine().Split("-");
  20. if (token[0] == "End of season")
  21. {
  22. break;
  23. }
  24. //take imput values
  25. string players = token[0];
  26. int amount =int.Parse(token[1]);
  27. //int amount = int.Parse(Console.ReadLine());
  28.  
  29. if (goals.ContainsKey(players))
  30. {
  31. goals[players] += amount;
  32. }
  33. else
  34. {
  35. goals.Add(players, amount);
  36. }
  37. } while (true);
  38.  
  39. //goals.OrderBy(x => x.Key)
  40. foreach (var pair in goals.OrderBy(x => x.Key))
  41. {
  42.  
  43. Console.WriteLine("{0} -> {1}", pair.Key, pair.Value);
  44. }
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement