Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp2
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool programopen = true;
- Console.WriteLine("Придуайте пароль:");
- string password=Console.ReadLine();
- int schetchik = 0;
- while ( programopen==true)
- {
- Console.WriteLine("Введите пожалуйста пароль:");
- string trypassword = Console.ReadLine();
- if (trypassword == password)
- {
- Console.WriteLine("Секретное сообщение!");
- }
- else
- {
- Console.WriteLine("Неверно!");
- schetchik += 1; //увеличение счётчика при неправильном вводе
- }
- if(schetchik==5)
- {
- Console.WriteLine("Число попыток исперпано!");
- programopen = false;//флаг выхода из программы
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment