Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace homework
- {
- class Program
- {
- static void Main(string[] args)
- {
- const string pass = "qwerty", secret = "https://www.youtube.com/watch?v=dQw4w9WgXcQ";
- string Password = "";
- for (int i = 0; i < 5; i++)
- {
- Console.Write("Введите пароль: ");
- while (true)
- {
- ConsoleKeyInfo CharKey = Console.ReadKey(true);
- if (CharKey.Key == ConsoleKey.Enter)
- {
- if (pass == Password)
- {
- Console.Clear();
- Console.SetCursorPosition(Console.WindowWidth / 2 - secret.Length / 2, Console.WindowHeight / 2 - 1);
- Console.Write(secret);
- Console.SetCursorPosition(Console.WindowWidth / 2 - secret.Length / 2, Console.WindowHeight / 2 + 1);
- return;
- }
- else
- {
- Console.WriteLine("\nПароль неверный! Осталось попыток: "+(5-i-1));
- }
- break;
- }
- else if (CharKey.Key == ConsoleKey.Backspace)
- {
- Password = Password.Remove(Password.Length - 1);
- Console.Write("\b \b");
- }
- else
- {
- Password += CharKey.KeyChar;
- Console.Write("*");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement