Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
- using System;
- using System.IO;
- using System.Linq;
- using System.Collections.Generic;
- namespace CSharp_Shell
- {
- public static class Program
- {
- public static void Main()
- {
- var dict = new Dictionary<string, int>();
- var count = -1;
- var resource = string.Empty;
- var quantity = 0;
- while(true)
- {
- var input = Console.ReadLine();
- count++;
- if(input == "stop")
- {
- break;
- }
- if(count%2==0)
- {
- resource = input;
- if(!dict.ContainsKey(resource))
- {
- dict[resource] = new int();
- }
- }
- else
- {
- quantity = int.Parse(input);
- dict[resource]+=quantity;
- }
- }
- foreach(var kvp in dict)
- {
- Console.WriteLine($"{kvp.Key} -> {kvp.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement