Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Football
- {
- class Program
- {
- static void Main()
- {
- Dictionary<string, int> dict = new Dictionary<string, int>();
- while (true)
- {
- string input = Console.ReadLine();
- if (input == "End of season")
- {
- break;
- }
- string[] playerArgs = input.Split(" - ");
- string name = playerArgs[0];
- int goals = int.Parse(playerArgs[1]);
- if (dict.ContainsKey(name) == false)
- {
- dict[name] = 0;
- }
- dict[name] += goals;
- }
- foreach (var player in dict.OrderBy(x => x.Key).ThenBy(g => g.Value))
- {
- Console.WriteLine($"{player.Key} -> {player.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement