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)
- {
- var number = int.Parse(Console.ReadLine());
- var wardrobe = new Dictionary<string, Dictionary<string, int>>();
- bool clothesForAdd = false;
- for (int i = 0; i < number; i++)
- {
- string[] command = Console.ReadLine().Split(" -> ", StringSplitOptions.RemoveEmptyEntries);
- string color = command[0];
- if (!wardrobe.ContainsKey(color))
- {
- wardrobe.Add(color, new Dictionary<string, int>());
- }
- string[] clothes = command[1].Split(',', StringSplitOptions.RemoveEmptyEntries);
- if (!clothesForAdd)
- {
- for (int y = 0; y < clothes.Length; y++)
- {
- string item = clothes[y];
- if (!wardrobe[color].ContainsKey(item))
- {
- wardrobe[color].Add(item, 1);
- }
- else
- {
- wardrobe[color][item] += 1;
- }
- }
- }
- }
- string[] input = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray();
- string colors = input[0];
- string clothesForResult = input[1];
- foreach (var items in wardrobe)
- {
- Console.WriteLine($"{items.Key} clothes:");
- foreach (var item in items.Value)
- {
- Console.Write($"* {item.Key} - {item.Value}");
- if (items.Key == colors && item.Key == clothesForResult)
- {
- Console.Write(" (found!)");
- }
- Console.WriteLine();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement