Advertisement
bacco

aMinerTask

Jun 20th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace aMinerTask
  6. {
  7.     class MainClass
  8.     {
  9.         public static void Main(string[] args)
  10.  
  11.         {
  12.             var metals = new Dictionary<string, int>();
  13.  
  14.             while (true)
  15.             {
  16.                 var input = Console.ReadLine();
  17.  
  18.                 if (input.Equals("stop"))
  19.                 {
  20.                     break;
  21.                 }
  22.  
  23.                 var quantity = int.Parse(Console.ReadLine());
  24.  
  25.  
  26.                 if ( ! metals.ContainsKey(input) )
  27.                 {
  28.                     metals[input] = 0;
  29.                 }
  30.                 metals[input] += quantity;
  31.  
  32.             }
  33.  
  34.             foreach (var pair in metals)
  35.             {
  36.                 Console.WriteLine($"{pair.Key} -> {pair.Value}");
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement