Advertisement
Guest User

Untitled

a guest
Jul 7th, 2020
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _03._Word_Synonyms
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int n = int.Parse(Console.ReadLine());
  12.  
  13. var counts = new Dictionary<string, List<string>>();
  14.  
  15. string key = string.Empty;
  16.  
  17. for (int i = 1; i <= 2 * n; i++)
  18. {
  19. string input = Console.ReadLine();
  20. if (i % 2 != 0)
  21. {
  22. if(!(counts.ContainsKey(input)))
  23. {
  24. counts.Add(input, new List<string>());
  25. key = input;
  26. }
  27. }
  28. else
  29. {
  30. counts[key].Add(input);
  31. }
  32. }
  33. foreach (var word in counts)
  34. {
  35. Console.WriteLine($"{word.Key} - {string.Join(", ", word.Value)}");
  36. }
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement