Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _03._Word_Synonyms
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- var counts = new Dictionary<string, List<string>>();
- string key = string.Empty;
- for (int i = 1; i <= 2 * n; i++)
- {
- string input = Console.ReadLine();
- if (i % 2 != 0)
- {
- if(!(counts.ContainsKey(input)))
- {
- counts.Add(input, new List<string>());
- key = input;
- }
- }
- else
- {
- counts[key].Add(input);
- }
- }
- foreach (var word in counts)
- {
- Console.WriteLine($"{word.Key} - {string.Join(", ", word.Value)}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement