Advertisement
PetarNeshkov5360

Wardrobe

Apr 24th, 2021
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. int counter = int.Parse(Console.ReadLine());
  2. Dictionary<string, Dictionary<string, int>> dc = new Dictionary<string, Dictionary<string, int>>();
  3. for (int i = 0; i < counter; i++)
  4. {
  5. string[] input = Console.ReadLine().Split(" -> ",StringSplitOptions.RemoveEmptyEntries);
  6. string color = input[0];
  7. string []dresses = input[1].Split(",");
  8. if (!dc.ContainsKey(color))
  9. {
  10. dc.Add(color, new Dictionary<string, int>());
  11. }
  12. for (int k = 0; k < dresses.Length; k++)
  13. {
  14. string currDress = dresses[k];
  15. if (!dc[color].ContainsKey(currDress))
  16. {
  17. dc[color].Add(currDress, 0);
  18. }
  19. dc[color][currDress]++;
  20. }
  21. }
  22. string[] LookingItem = Console.ReadLine().Split();
  23. string lookingColor = LookingItem[0];
  24. string lookingDress = LookingItem[1];
  25. foreach (var clothes in dc)
  26. {
  27. Console.WriteLine($"{clothes.Key} clothes:");
  28. foreach (var item in clothes.Value)
  29. {
  30. if (lookingColor==clothes.Key && lookingDress==item.Key)
  31. {
  32. Console.WriteLine($"* {item.Key} - {item.Value} (found!)");
  33. }
  34. else
  35. {
  36. Console.WriteLine($"* {item.Key} - {item.Value}");
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement