Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _01._Dictionary
- {
- class Program
- {
- static void Main()
- {
- var words = new Dictionary<string, List<string>>();
- var firstLine = Console.ReadLine().Split(" | ");
- for (int i = 0; i < firstLine.Length; i++)
- {
- var wordsWithDefinitions = firstLine[i].Split(": ");
- var word = wordsWithDefinitions[0];
- var definition = wordsWithDefinitions[1];
- if (!words.ContainsKey(word))
- {
- words[word] = new List<string>();
- words[word].Add(definition);
- }
- else if (words.ContainsKey(word) && !words[word].Contains(definition))
- {
- words[word].Add(definition);
- }
- }
- var secondLine = Console.ReadLine().Split(" | ");
- for (int i = 0; i < secondLine.Length; i++)
- {
- if (words.ContainsKey(secondLine[i]))
- {
- Console.WriteLine($"{secondLine[i]}");
- foreach (var definition in words[secondLine[i]].OrderByDescending(x => x.Length))
- {
- Console.WriteLine($" -{definition}");
- }
- }
- }
- var thirdLine = Console.ReadLine();
- if (thirdLine == "End")
- {
- return;
- }
- else if (thirdLine == "List")
- {
- foreach (var word in words.OrderBy(x => x.Key))
- {
- Console.Write($"{word.Key}" + " ");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment