Last active
April 19, 2023 22:36
-
-
Save ShamilAitov/70a9fa65fc1594b92480536dec6c3138 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace Коллекции1задание | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string userInput; | |
bool bookNotFound = true; | |
Dictionary<string, string> text = new Dictionary<string, string> | |
{ | |
{ "Цвет", "Зеленый" }, | |
{ "Машина", "Мерседес" }, | |
{ "Недвижимость", "Коттедж"}, | |
{ "Деньги", "Крипта"}, | |
{ "Драгоценность", "Золото"}, | |
{ "Работа", "Разработчик" }, | |
{ "Город", "Пенза" } | |
}; | |
while (bookNotFound) | |
{ | |
if (FindingWord(text, out userInput)) | |
{ | |
Console.WriteLine($"Найдено слово по ключу {userInput}: " + text[userInput]); | |
bookNotFound = false; | |
} | |
else | |
{ | |
Console.WriteLine("Такого слова нет, попройбуйте еще раз!"); | |
} | |
} | |
} | |
static bool FindingWord(Dictionary<string, string> text, out string userInput) | |
{ | |
Console.Write("Введите слово, которое нужно найти: "); | |
userInput = Console.ReadLine(); | |
return text.ContainsKey(userInput); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment