Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Clight_15
- {
- class Program
- {
- static void Main()
- {
- string password = "game";
- string secretMessage = "Hello, world!";
- string userInput;
- int attemptsCount = 3;
- for (int i = 1; i <= attemptsCount; i++)
- {
- Console.Clear();
- Console.Write("Введите пароль: ");
- userInput = Console.ReadLine();
- Console.Clear();
- if (userInput == password)
- {
- Console.Write($"Секретное сообщение: {secretMessage}\n");
- Console.Write("Для выхода нажмите любую клавишу");
- Console.ReadKey();
- return;
- }
- else
- {
- Console.WriteLine($"Пароль введён не верно. Осталось попыток: {attemptsCount - i}.\n");
- Console.Write("Для повторного ввода пароля нажмите любую клавишу");
- Console.ReadKey();
- }
- }
- Console.Clear();
- Console.WriteLine("Попытки ввода пароля истекли.\n");
- Console.Write("Для выхода нажмите любую клавишу");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement