Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace _06._Wardrobe
- {
- class Wardrobe
- {
- static void Main(string[] args)
- {
- int lines = int.Parse(Console.ReadLine());
- var colorClothCount = new Dictionary<string, Dictionary<string, int>>();
- for (int i = 0; i < lines; i++)
- {
- string[] colorClotes = Console.ReadLine().Split(" -> ", StringSplitOptions.RemoveEmptyEntries);
- string color = colorClotes[0];
- string[] clothes = colorClotes[1].Split(',');
- if (colorClothCount.ContainsKey(color) == false) // !colorClothCount.ContainsKey(color)
- {
- colorClothCount[color] = new Dictionary<string, int>();
- }
- for (int j = 0; j < clothes.Length; j++)
- {
- string cloth = clothes[j];
- if (!colorClothCount[color].ContainsKey(cloth))
- {
- colorClothCount[color][cloth] = 0;
- }
- colorClothCount[color][cloth]++;
- }
- }
- string[] search = Console.ReadLine().Split();
- string colorToSearch = search[0];
- string clothToSearch = search[1];
- foreach (var kvp in colorClothCount)
- {
- string color = kvp.Key;
- var clothCount = kvp.Value;
- Console.WriteLine($"{color} clothes:");
- foreach (var kvpClothCount in clothCount)
- {
- string cloth = kvpClothCount.Key;
- int count = kvpClothCount.Value;
- if (clothToSearch == cloth && clothToSearch == cloth)
- {
- Console.WriteLine($"* {cloth} - {count} (found!)");
- }
- else
- {
- Console.WriteLine($"* {cloth} - {count}");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement