Advertisement
Guest User

Untitled

a guest
Feb 7th, 2017
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1.  
  2. namespace _03.AMinerTask
  3. {
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9.  
  10. class AMinerTask
  11. {
  12. static void Main(string[] args)
  13. {
  14. var dictionary = new Dictionary<string, int>();
  15. int value;
  16. string material = Console.ReadLine()
  17. .Trim();
  18.  
  19.  
  20. while (material != "stop")
  21. {
  22. value = int.Parse(Console.ReadLine()
  23. .Trim());
  24.  
  25. if (dictionary.ContainsKey(material))
  26. {
  27. dictionary[material] += value;
  28. }
  29. else
  30. {
  31. dictionary.Add(material, value);
  32. }
  33.  
  34. material = Console.ReadLine();
  35. }
  36.  
  37. foreach (var item in dictionary)
  38. {
  39. Console.WriteLine("{0} -> {1}", item.Key, item.Value);
  40. }
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement