Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- string password = "0000";
- int attemptsCount = 3;
- string secretMessage = "Секретное сообщение";
- for (int i = 1; i <= attemptsCount; i++)
- {
- Console.Write("Введите пароль: ");
- string userInput = Console.ReadLine();
- if (userInput == password)
- {
- Console.WriteLine($"Пароль верный!\n{secretMessage}");
- break;
- }
- else
- {
- int remainAttemptsCount = attemptsCount - i;
- Console.WriteLine($"Пароль неверный!\nОсталось попыток: {remainAttemptsCount}\n");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment