Advertisement
Guest User

03. A Miner Task

a guest
Oct 15th, 2017
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 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 _03.AMinerTask
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string a = Console.ReadLine();
  14.             int br = 1;
  15.             var resources = new Dictionary<string, string>();
  16.             string m="";
  17.  
  18.             while (a!="stop")
  19.             {
  20.                 if (br%2!=0)
  21.                 {
  22.                     m = a;
  23.                 }
  24.  
  25.                 else
  26.                 {
  27.                     string str;
  28.                     if (resources.TryGetValue(m, out str))
  29.                     {
  30.                         resources[m] = a;
  31.                     }
  32.  
  33.                     else
  34.                     {
  35.                         resources.Add(m, a);
  36.                     }
  37.                 }
  38.  
  39.                 br++;
  40.                 a = Console.ReadLine();
  41.             }
  42.  
  43.             foreach (var item in resources.Keys)
  44.             {
  45.                 Console.WriteLine($"{item} -> {resources[item]}");
  46.             }
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement