Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Dictionary
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] pairsOgi = Console.ReadLine().Split(" | ");
- var wordsFromOgi = new Dictionary<string, List<string>>();
- foreach (var pair in pairsOgi)
- {
- string[] infoForYourWord = pair.Split(": ");
- string wordFromOgi = infoForYourWord[0];
- string definitionFromOgi = infoForYourWord[1];
- if (wordsFromOgi.ContainsKey(wordFromOgi))
- {
- wordsFromOgi[wordFromOgi].Add(definitionFromOgi);
- continue;
- }
- List<string> definitions = new List<string>();
- definitions.Add(definitionFromOgi);
- wordsFromOgi.Add(wordFromOgi, definitions);
- }
- string[] anotherWords = Console.ReadLine().Split(" | ");
- string command = Console.ReadLine();
- if (command == "Hand Over")
- {
- Console.WriteLine(string.Join(" ", wordsFromOgi.Keys));
- }
- else if (command == "Test")
- {
- List<string> wordsForTest = new List<string>();
- foreach (var word in anotherWords)
- {
- if (wordsFromOgi.ContainsKey(word))
- {
- wordsForTest.Add(word);
- }
- }
- foreach (var word in wordsForTest)
- {
- var definitions = wordsFromOgi[word];
- Console.WriteLine($"{word}:");
- foreach (var definition in definitions)
- {
- Console.WriteLine($" -{definition}");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement