Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using System.Linq;
- namespace _1.Dictionary_FinalExam_06._04._2019
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, List<string>> dict = new Dictionary<string, List<string>>();
- string input = Console.ReadLine();
- string inputWord = Console.ReadLine();
- string endLine = Console.ReadLine();
- //while (input != "List" || input != "End")
- //{ // string definition = word[1];// }
- string[] word = input.Split(" | ");
- for (int i = 0; i < word.Length; i++)
- {
- string[] newWord = word[i].Split(": ");
- string wordKey = newWord[0];
- string def = newWord[1];
- if (!dict.ContainsKey(wordKey))
- {
- dict[wordKey] = new List<string>();
- }
- dict[wordKey].Add(def);
- }
- string[] splitedInputW = inputWord.Split(" | ");
- for (int i = 0; i < splitedInputW.Length; i++)
- {
- string findWord = splitedInputW[i];
- if (dict.ContainsKey(findWord))
- {
- foreach (var item in dict.OrderBy(x => x.Key))
- {
- Console.WriteLine($"{item.Key} ");
- foreach (var definition in item.Value.OrderByDescending(x=>x.Length))
- {
- Console.WriteLine($" -{definition}");
- }
- //foreach (var definition in dict.Values.OrderByDescending(x => x))
- //{
- // Console.WriteLine($" --{definition}");
- //}
- }
- }
- break;
- }
- if (endLine == "List")
- {
- foreach (var item in dict.OrderBy(x => x.Key))
- {
- Console.Write($"{item.Key} ");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement