Advertisement
debono

Untitled

Oct 16th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 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 Miner__Task
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var minerCounting = new Dictionary<string, long>();
  14.  
  15.             while (true)
  16.             {
  17.                 string input = Console.ReadLine().ToLower();
  18.  
  19.                 if (input == "stop")
  20.                 {
  21.                     break;
  22.                 }
  23.  
  24.                 long quantity = long.Parse(Console.ReadLine());
  25.  
  26.                 if (minerCounting.ContainsKey(input))
  27.                 {
  28.                     minerCounting[input] += quantity;
  29.                 }
  30.                 else
  31.                 {
  32.                     minerCounting.Add(input, quantity);
  33.                 }
  34.             }
  35.  
  36.             foreach (var item in minerCounting)
  37.             {
  38.                 Console.WriteLine("{0} -> {1}", item.Key, item.Value);
  39.             }
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement