Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Wardrobe_Exercises_Sets_and_Dictionaries
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- Dictionary<string, Dictionary<string, int>> wardrobe = new Dictionary<string, Dictionary<string, int>>();
- for (int i = 0; i < n; i++)
- {
- string[] inputData = Console.ReadLine()
- .Split(" -> ");
- string color = inputData[0];
- string[] dresses = inputData[1].Split(",");
- if (!wardrobe.ContainsKey(color))
- {
- wardrobe.Add(color, new Dictionary<string, int>());
- }
- foreach (var dress in dresses)
- {
- if (!wardrobe[color].ContainsKey(dress))
- {
- wardrobe[color].Add(dress, 0);
- }
- wardrobe[color][dress]++;
- }
- }
- string[] findingDress = Console.ReadLine().Split(" ");
- string enteredColor = findingDress[0];
- string clothing = findingDress[1];
- foreach (var (color, values) in wardrobe)
- {
- Console.WriteLine($"{color} clothes:");
- Dictionary<string, int> clothes = values;
- foreach (var dress in clothes)
- {
- string result = $"* {dress.Key} - {dress.Value}";
- if (enteredColor == color && clothing == dress.Key)
- {
- result += " (found!)";
- }
- Console.WriteLine(result);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment