Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text;
- using System.Collections.Generic;
- namespace Exercise
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- var dictionary = new Dictionary<string, int>();
- while(input != “End of season”)
- {
- var tokens = input.Split(“ - ”).ToArray();
- string playerName = tokens[0];
- int goals = int.Parse(tokens[1]);
- if(!dictionary.ContainsKey(playerName))
- {
- dictionary.Add(playerName, goals);
- }
- else
- {
- dictionary[playerName] += goals;
- }
- input = Console.ReadLine();
- }
- foreach(var kvp in dictionary.OrderBy(x => x.Key))
- {
- Console.WriteLine($”{kvp.Key} - {kvp.Value}”)
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement