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