Advertisement
MARINA_GREBENAROVA

Word_Synonyms

Mar 27th, 2022
863
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Word_Synonyms
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             int n = int.Parse(Console.ReadLine());
  12.             Dictionary<string, List<string>> wordSynonyms = new Dictionary<string, List<string>>();
  13.  
  14.  
  15.             for (int i = 0; i < n; i++)
  16.             {
  17.                 string word = Console.ReadLine();
  18.                 string synonym = Console.ReadLine();
  19.  
  20.                 if (!wordSynonyms.ContainsKey(word))
  21.                 {
  22.                     wordSynonyms.Add(word, new List<string>());
  23.                 }
  24.                 wordSynonyms[word].Add(synonym);
  25.             }
  26.             foreach (var word in wordSynonyms)
  27.             {
  28.                 Console.WriteLine($"{word.Key} - {String.Join(", ", word.Value)}");
  29.             }
  30.                
  31.         }
  32.     }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement