Advertisement
nikolapetkov824

DemoFinalExam01

Dec 7th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.98 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5.  
  6. namespace SoftUniExamResults
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             Dictionary<string, List<string>> map =
  13.                 new Dictionary<string, List<string>>();
  14.  
  15.  
  16.             string[] one = Console.ReadLine().Split(" | ");
  17.  
  18.             for (int i = 0; i < one.Length; i++)
  19.             {
  20.                 string[] splitted = one[i].Split(": ");
  21.  
  22.                 string word = splitted[0];
  23.                 string definition = splitted[1];
  24.  
  25.                 if (!map.ContainsKey(word))
  26.                 {
  27.                     map.Add(word, new List<string>());
  28.                 }
  29.  
  30.                 map[word].Add(definition);
  31.             }
  32.  
  33.             string[] two = Console.ReadLine().Split(" | ");
  34.  
  35.             for (int i = 0; i < two.Length; i++)
  36.             {
  37.                 string word = two[i];
  38.  
  39.                 if (map.ContainsKey(word))
  40.                 {
  41.                     foreach (var worD in map.OrderBy(x=>x.Key))
  42.                     {
  43.                         if (worD.Key == word)
  44.                         {
  45.                             Console.WriteLine(worD.Key);
  46.  
  47.                             foreach (var definition in worD.Value.OrderByDescending(x=>x.Length))
  48.                             {
  49.                                 Console.WriteLine($"-{definition}");
  50.                             }
  51.                         }
  52.  
  53.                        
  54.                     }
  55.                     //break;
  56.                 }
  57.             }
  58.  
  59.  
  60.             string three = Console.ReadLine();
  61.             if (three=="End")
  62.             {
  63.                 return;
  64.             }
  65.             if (three=="List")
  66.             {
  67.                 foreach (var word in map.OrderBy(x=>x.Key))
  68.                 {
  69.                     Console.Write(word.Key + " ");
  70.                 }
  71.             }
  72.             Console.WriteLine();
  73.         }
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement