Advertisement
loter

Wardrobe1

Mar 18th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ConsoleApp1
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int count = int.Parse(Console.ReadLine());
  12. Dictionary<string, Dictionary<string, int>> wardrobe = new Dictionary<string, Dictionary<string, int>>();
  13.  
  14. for (int i = 0; i < count; i++)
  15. {
  16. string[] input = Console.ReadLine().Split(new string[] { "->", " "} , StringSplitOptions.RemoveEmptyEntries).ToArray();
  17. string[] clothes = input[1].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
  18. Dictionary<string, int> clothesAll = new Dictionary<string, int>();
  19.  
  20. if (wardrobe.ContainsKey(input[0]) == false)
  21. {
  22. for (int j = 0; j < clothes.Length; j++)
  23. {
  24. if (clothesAll.ContainsKey(clothes[j]) == false)
  25. {
  26. clothesAll.Add(clothes[j], 1);
  27. }
  28. else
  29. {
  30. clothesAll[clothes[j]] += 1;
  31. }
  32. }
  33.  
  34. wardrobe.Add(input[0], clothesAll);
  35. }
  36. else
  37. {
  38. foreach (var item in clothes)
  39. {
  40. if (wardrobe[input[0]].ContainsKey(item) == false)
  41.  
  42. {
  43. wardrobe[input[0]].Add(item, 1);
  44. }
  45. else
  46. {
  47. wardrobe[input[0]][item]++;
  48. }
  49. }
  50. }
  51. }
  52.  
  53. string[] inputNeeded = Console.ReadLine().Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries).ToArray();
  54.  
  55. foreach (var color in wardrobe)
  56. {
  57. Console.WriteLine($"{color.Key} clothes:");
  58. foreach (var item in color.Value)
  59. {
  60. if (color.Key == inputNeeded[0] && item.Key == inputNeeded[1])
  61. {
  62. Console.WriteLine($"* {item.Key} - {item.Value} (found!)");
  63. }
  64. else
  65. {
  66. Console.WriteLine($"* {item.Key} - {item.Value}");
  67. }
  68. }
  69. }
  70. }
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement