Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class Program
- {
- static void Main()
- {
- string keyFromUser = Console.ReadLine();
- string valueFromUser = Console.ReadLine();
- int lines = int.Parse(Console.ReadLine());
- var dict = new Dictionary<string, List<string>>();
- for (int i = 0; i < lines; i++)
- {
- string[] tokens = Console.ReadLine().Split(new string[] { " => " }, StringSplitOptions.RemoveEmptyEntries);
- string key = tokens[0];
- string[] value = tokens[1].Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
- if (key.Contains(keyFromUser))
- {
- if (!dict.ContainsKey(key))
- {
- dict.Add(key, new List<string>());
- }
- foreach (var item in value)
- {
- if (valueFromUser.Contains(item) || item.Contains(valueFromUser))
- {
- dict[key].Add(item);
- }
- }
- }
- }
- foreach (var item in dict)
- {
- string keyBase = item.Key;
- Console.WriteLine($"{keyBase}:");
- foreach (var token in item.Value)
- {
- Console.WriteLine($"-{token}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement