Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. class Program
  6. {
  7. static void Main()
  8. {
  9. string key = Console.ReadLine();
  10. string input = Console.ReadLine();
  11. int n = int.Parse(Console.ReadLine());
  12. var dict = new Dictionary<string, List<string>>();
  13.  
  14. for (int i = 0; i < n; i++)
  15. {
  16. string[] inputTokens = Console.ReadLine().Split(new string[] { "=>" }, StringSplitOptions.RemoveEmptyEntries);
  17. string inputKey = inputTokens[0];
  18. string[] inputValue = inputTokens[1].Split(';');
  19.  
  20. if (inputKey.Contains(key))
  21. {
  22. if (!dict.ContainsKey(inputKey))
  23. {
  24. dict.Add(inputKey, new List<string>());
  25. }
  26. }
  27. foreach (var value in inputValue)
  28. {
  29. if (input.Contains(value) || value.Contains(input))
  30. {
  31. dict[inputKey].Add(value);
  32. }
  33. }
  34. }
  35.  
  36. foreach (var item in dict)
  37. {
  38. Console.WriteLine($"{item.Key}:");
  39. foreach (var values in item.Value)
  40. {
  41. Console.WriteLine($"-{values}");
  42. }
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement