W1thr

Коллекции-1

Mar 6th, 2021 (edited)
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Homework1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             bool exit = false;
  14.             Dictionary<string, string> dictionary = new Dictionary<string, string>();
  15.             dictionary.Add("Аберрация", "Искажение наблюдаемых явлений, отход от истинности");
  16.             dictionary.Add("Гамбит", "Приём в шахматной партии, когда игрок сознательно подставляет и жертвует фигуры, с целью получения преимущества при дальнейшем развитии игры");
  17.             dictionary.Add("Герменевтика", "Неизлечимость");
  18.             dictionary.Add("Ультиматум", "Решительное и бескомпромиссное требование, сопровождаемое угрозой");
  19.             dictionary.Add("Цессия", "Передача своих прав другому лицу");
  20.  
  21.             while (exit == false)
  22.             {
  23.                 foreach (var word in dictionary)
  24.                 {
  25.                     Console.WriteLine(word.Key);
  26.                 }
  27.                 Console.WriteLine();
  28.  
  29.                 Console.Write("Введите слово, чтобы узнать его значение(либо 'exit' для выхода):");
  30.                 string userInput = Console.ReadLine();
  31.  
  32.                 if (dictionary.ContainsKey(userInput))
  33.                 {
  34.                     Console.WriteLine($"{userInput} - {dictionary[userInput]}");
  35.                 }
  36.                 else if (userInput == "exit")
  37.                 {
  38.                     exit = true;
  39.                 }
  40.                 else
  41.                 {
  42.                     Console.WriteLine("Слово введено неверно!");
  43.                 }
  44.                 Console.ReadKey();
  45.                 Console.Clear();
  46.             }
  47.  
  48.         }
  49.     }
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment