SHARE
TWEET

Untitled

a guest Mar 20th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace A_Miner_Task
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             Dictionary<string, int> resourcesAndQuantities = new Dictionary<string, int>();
  12.  
  13.             while (true)
  14.             {
  15.                 string resources = Console.ReadLine();
  16.                 if (resources == "stop")
  17.                 {
  18.                     break;
  19.                 }
  20.                 int quantity = int.Parse(Console.ReadLine());
  21.                 if (!resourcesAndQuantities.ContainsKey(resources))
  22.                 {
  23.                     resourcesAndQuantities.Add(resources, 0);
  24.  
  25.                 }
  26.                 resourcesAndQuantities[resources] += quantity;
  27.             }
  28.  
  29.             foreach (var type in resourcesAndQuantities)
  30.             {
  31.                 Console.WriteLine($"{type.Key} -> {type.Value}");
  32.             }
  33.         }
  34.     }
  35. }
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
 
Top