Advertisement
martinvalchev

A_Miner_Task

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