Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Dictionary
- {
- class Program
- {
- public static void Main()
- {
- var dictionary = new Dictionary<string, List<string>>();
- var counter = 0;
- while (true)
- {
- var input = Console.ReadLine()
- .Split(" | ")
- .ToList();
- counter++;
- if (input[0] == "End")
- {
- break;
- }
- if (input[0] == "List")
- {
- foreach (var word in dictionary.OrderBy(w=>w.Key))
- {
- Console.Write(word.Key + " ");
- }
- Console.WriteLine();
- break;
- }
- if (counter == 1)
- {
- for (int i = 0; i < input.Count; i++)
- {
- var splittedInput = input[i].Split(": ");
- var word = splittedInput[0];
- var meaning = splittedInput[1];
- if (!dictionary.ContainsKey(word))
- {
- dictionary[word] = new List<string> { meaning };
- }
- else
- {
- dictionary[word].Add(meaning);
- }
- }
- }
- if (counter == 2)
- {
- for (int i = 0; i < input.Count; i++)
- {
- var word = input[i];
- if (dictionary.ContainsKey(word))
- {
- Console.WriteLine(word);
- foreach (var meaning in dictionary[word].OrderByDescending(m=>m.Length))
- {
- Console.WriteLine($" -{meaning}");
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement