Advertisement
martyz

Miner Task

Oct 16th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 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 MinerTask
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string input = Console.ReadLine();
  14.             var dict = new Dictionary<string, int>();
  15.  
  16.             while (input != "stop")
  17.             {
  18.                 if (dict.ContainsKey(input))
  19.                 {
  20.                     dict[input] += int.Parse(Console.ReadLine());
  21.                 }
  22.                 else
  23.                 {
  24.                     dict[input] = int.Parse(Console.ReadLine());
  25.                 }
  26.                 input = Console.ReadLine();
  27.             }
  28.             Console.WriteLine(String.Join("\n", dict.Select(x => x.Key + " -> " + x.Value)));
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement