Advertisement
Rodunskiy

Untitled

Jun 3rd, 2023
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. class program
  2. {
  3.     static void Main(string[] args)
  4.     {
  5.         bool isFound = true;
  6.         Dictionary<string, string> explanatoryDictionary = new Dictionary<string, string>();
  7.         explanatoryDictionary.Add("Футбол", "Football");
  8.         explanatoryDictionary.Add("Баскетбол", "Basketball");
  9.         explanatoryDictionary.Add("Хоккей", "Hockey");
  10.         explanatoryDictionary.Add("Теннис", "Tennis");
  11.         explanatoryDictionary.Add("Гольф", "Golf");
  12.  
  13.         Console.Write("Введите слово:");
  14.         string userInput = Console.ReadLine();
  15.  
  16.         foreach(var item in explanatoryDictionary)
  17.         {
  18.             if (item.Key == userInput)
  19.             {
  20.                 Console.WriteLine(item.Value);
  21.                 isFound = false;
  22.             }
  23.         }
  24.  
  25.         if (isFound == true)
  26.         {
  27.             Console.WriteLine("Такого слова нет.");
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement