SHARE
TWEET

FootballSeason

a guest Mar 24th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Linq;
  3. using System.Text;
  4. using System.Collections.Generic;
  5.  
  6. namespace Exercise
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             string input = Console.ReadLine();
  13.  
  14.             var dictionary = new Dictionary<string, int>();
  15.  
  16.             while(input != “End of season”)
  17.             {
  18.                var tokens = input.Split(-).ToArray();
  19.                string playerName = tokens[0];
  20.                int goals = int.Parse(tokens[1]);
  21.  
  22.                if(!dictionary.ContainsKey(playerName))
  23.                {
  24.                   dictionary.Add(playerName, goals);
  25.                }
  26.                else
  27.                {
  28.                   dictionary[playerName] += goals;
  29.                }
  30.                
  31.                input = Console.ReadLine();
  32.             }
  33.  
  34.            foreach(var kvp in dictionary.OrderBy(x => x.Key))
  35.            {
  36.              Console.WriteLine($”{kvp.Key} - {kvp.Value})
  37.            }
  38.         }
  39.     }
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top