Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> dankalove = Console.ReadLine().Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).ToList();
- string[] words = Console.ReadLine().Split(new[] { '|', ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
- string command = Console.ReadLine();
- Dictionary<string, List<string>> dictionary = new Dictionary<string, List<string>>();
- for (int i = 0; i < dankalove.Count; i++)
- {
- string[] temporary = dankalove[i].Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
- temporary[0] = temporary[0].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray()[0];
- if (dictionary.ContainsKey(temporary[0]))
- {
- List<string> previous = dictionary[temporary[0]];
- previous.Add(temporary[1]);
- dictionary[temporary[0]] = previous;
- }else
- {
- List<string> definition = new List<string>();
- definition.Add(temporary[1]);
- dictionary.Add(temporary[0], definition);
- }
- }
- if(command == "List")
- {
- var wordsOutput = dictionary.Keys.ToList();
- wordsOutput.Sort();
- for(int i = 0; i < wordsOutput.Count; i++)
- {
- Console.Write(wordsOutput[i] + " ");
- }
- Console.WriteLine();
- }
- if(command == "End")
- {
- var wordsOutput = dictionary.Keys.ToList();
- wordsOutput.Sort();
- for (int i = 0; i < wordsOutput.Count; i++)
- {
- Console.WriteLine(wordsOutput[i]);
- var definitions = dictionary[wordsOutput[i]];
- definitions.Sort();
- for (int j = 0; j < definitions.Count; j++)
- {
- Console.Write(" " + "-" + definitions[j].Substring(1));
- Console.WriteLine();
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement