Advertisement
Spocoman

02. A Miner Task

Apr 8th, 2023 (edited)
736
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace AMinerTask
  6. {
  7.     class Program
  8.     {
  9.         public static void Main()
  10.         {
  11.             Dictionary<string, int> resources = new Dictionary<string, int>();
  12.  
  13.             string command;
  14.  
  15.             while ((command = Console.ReadLine()) != "stop")
  16.             {
  17.                 if (!resources.ContainsKey(command))
  18.                 {
  19.                     resources.Add(command, 0);
  20.                 }
  21.  
  22.                 resources[command] += int.Parse(Console.ReadLine());
  23.             }
  24.  
  25.             foreach (var resource in resources)
  26.             {
  27.                 Console.WriteLine($"{resource.Key} -> {resource.Value}");
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement