Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace P09.Dictionary
- {
- class Program
- {
- static void Main(string[] args)
- {
- var words = Console.ReadLine().Split(" | ").ToList();
- var wordBox = new Dictionary<string, string>();
- var listOfWords = new List<string>();
- for (int i = 0; i < words.Count; i++)
- {
- var input = words[i].Split(": ").ToArray();
- string word = input[0];
- string definition = input[1];
- if (!wordBox.ContainsKey(word))
- {
- wordBox.Add(word, definition);
- listOfWords.Add(word);
- }
- }
- var words2 = Console.ReadLine().Split(" | ").ToList();
- string cmd = Console.ReadLine();
- if (cmd == "End")
- {
- for (int i = 0; i < words2.Count; i++)
- {
- if (wordBox.ContainsKey(words2[i]))
- {
- foreach (var word in wordBox)
- {
- if (words2[i] == word.Key)
- {
- foreach (var definition in word.Value.OrderByDescending(x=>x))
- {
- Console.WriteLine(word.Key);
- Console.WriteLine($" -{definition}");
- }
- }
- }
- }
- }
- }
- else if (cmd == "List")
- {
- foreach (var word in listOfWords.OrderBy(x => x))
- {
- Console.Write($"{word} ");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement