Advertisement
vinikol

03. A Miner Task

Oct 13th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 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.A_Miner_Task
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var minerTask = new Dictionary<string, int>();
  14. bool continueRead = true;
  15.  
  16. while (continueRead)
  17. {
  18. string material = Console.ReadLine();
  19.  
  20. if (material == "stop")
  21. {
  22. continueRead = false;
  23. foreach (var item in minerTask)
  24. {
  25. Console.WriteLine($"{item.Key} -> {item.Value}");
  26. }
  27. }
  28. else
  29. {
  30. int valueMaterial = int.Parse(Console.ReadLine());
  31.  
  32. if(minerTask.ContainsKey(material))
  33. {
  34. minerTask[material] += valueMaterial;
  35. }
  36. else
  37. {
  38. minerTask.Add(material, valueMaterial);
  39. }
  40.  
  41. }
  42. }
  43.  
  44.  
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement