Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace _04.PassStatistics
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- SortedDictionary<string, int> passesDict = new SortedDictionary<string, int>();
- string command = Console.ReadLine();
- while (command != "End of match")
- {
- string[] arrayPlayer = command.Split(" - ");
- string name = arrayPlayer[0];
- int passes = int.Parse(arrayPlayer[1]);
- if (!passesDict.ContainsKey(name))
- {
- passesDict[name] = passes;
- }
- else
- {
- int newCount = passesDict[name] + passes;
- passesDict[name] = newCount;
- }
- command = Console.ReadLine();
- }
- foreach (var entry in passesDict)
- {
- Console.WriteLine($"{entry.Key} has passed {entry.Value} passes.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement