Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Homework15
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- string password = "1234";
- int triesCount = 3;
- int remainTriesCount;
- int wastedTry = 1;
- string secretMassage = "Колобок повесился";
- Console.WriteLine($"Введите верный пароль чтобы узнать секретное сообщение, у вас есть {triesCount} попытки!");
- for (int i = 0; i < triesCount; i++)
- {
- string userInput = Console.ReadLine();
- Console.Clear();
- if (userInput == password)
- {
- Console.WriteLine(secretMassage);
- break;
- }
- else
- {
- remainTriesCount = triesCount - (i + wastedTry);
- Console.WriteLine($"Неверный пароль! У вас осталось {remainTriesCount} попыток");
- }
- }
- Console.WriteLine("Выход из программы!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement