Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- namespace DictionaryExam
- {
- class Program
- {
- static void Main(string[] args)
- {
- var dictionary = new Dictionary<string, List<string>>();
- string[] wordsAndDefinitions = Console.ReadLine().Split(" | ");
- foreach (var item in wordsAndDefinitions)
- {
- string[] tokens = item.Split(": ");
- string word = tokens[0];
- if (!dictionary.ContainsKey(word))
- {
- dictionary.Add(word, new List<string>());
- }
- dictionary[word].Add(tokens[1]);
- }
- string[] onlyWords = Console.ReadLine().Split(" | ");
- foreach (var word in onlyWords)
- {
- if (dictionary.ContainsKey(word))
- {
- Console.WriteLine($"{word}:");
- var newList = dictionary[word].OrderByDescending(x=>x.Count());
- foreach (var item in newList)
- {
- Console.WriteLine($"-{item}");
- }
- }
- }
- string command = Console.ReadLine();
- if (command == "List")
- {
- foreach (var item in dictionary.OrderBy(x => x.Key))
- {
- Console.Write(item.Key + " ");
- }
- }
- else if (command == "End")
- {
- return;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement