Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace A_Miner_Task
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, int> resourcesAndQuantities = new Dictionary<string, int>();
- while (true)
- {
- string resources = Console.ReadLine();
- if (resources == "stop")
- {
- break;
- }
- int quantity = int.Parse(Console.ReadLine());
- if (!resourcesAndQuantities.ContainsKey(resources))
- {
- resourcesAndQuantities.Add(resources, 0);
- }
- resourcesAndQuantities[resources] += quantity;
- }
- foreach (var type in resourcesAndQuantities)
- {
- Console.WriteLine($"{type.Key} -> {type.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement