Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- /*
- * Сделайте счётчик неверных вводов пароля,
- * и при достижение числа 5, завершите программу.
- */
- int attempts = 5;
- while(true)
- {
- string password = Console.ReadLine();
- if (password == "admin")
- {
- Console.WriteLine("Secret message");
- break;
- }
- else
- {
- attempts--;
- Console.WriteLine("Wrong passport, you have only {0} attempts left", attempts);
- if (attempts==0)
- {
- Console.Clear();
- Console.WriteLine("\tYou have no more attempts\n\t\t Bye!");
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment