Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace _06._Wardrobe
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- Dictionary<string, Dictionary<string, int>> dict = new Dictionary<string, Dictionary<string, int>>();
- for (int i = 0; i < n; i++)
- {
- var input = Console.ReadLine()
- .Split("->", StringSplitOptions.RemoveEmptyEntries).ToArray();
- string color = input[0];
- var clothes = input[1].Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
- if (!dict.ContainsKey(color))
- {
- dict.Add(color, new Dictionary<string, int>());
- }
- for (int j = 0; j < clothes.Length; j++)
- {
- if (!dict[color].ContainsKey(clothes[j]))
- {
- dict[color].Add(clothes[j], 0);
- }
- dict[color][clothes[j]]++;
- }
- }
- var check = Console.ReadLine().Split().ToArray();
- string neededColor = check[0];
- string neededElement = check[1];
- foreach (var item in dict)
- {
- Console.WriteLine($"{item.Key} clothes:");
- foreach (var element in item.Value)
- {
- Console.Write($"* {element.Key} - {element.Value}");
- if (element.Key == neededElement && item.Key == neededColor)
- {
- Console.Write("(found!)");
- }
- Console.WriteLine();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement