Advertisement
DrDemonik

Untitled

Mar 12th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. Console.WriteLine("Введите пароль: ");
  2. string pass="",nextPass;
  3. ConsoleKeyInfo key;
  4. do//меняем вводимые знаки на звездочки
  5. {
  6.     key = Console.ReadKey(true);
  7.  
  8.     if (!Char.IsControl(key.KeyChar))//Проверка на клавиши контроля
  9.     {
  10.         Console.Write("*");
  11.     }
  12.     pass += key.KeyChar;
  13. } while (key.Key != ConsoleKey.Enter);
  14. int countFail = 0;
  15. do
  16. {
  17.     Console.WriteLine("\nВведите пароль повторн:");
  18.     nextPass = "";
  19.     do//меняем вводимые знаки на звездочки
  20.     {
  21.         key = Console.ReadKey(true);
  22.  
  23.         if (!Char.IsControl(key.KeyChar))//Проверка на клавиши контроля
  24.         {
  25.             Console.Write("*");
  26.         }
  27.         nextPass += key.KeyChar;
  28.     } while (key.Key != ConsoleKey.Enter);
  29.     if (pass == nextPass)
  30.     {
  31.         Console.WriteLine("\nСекретное сообщение: убийца плачет");
  32.         countFail = 10;
  33.     }
  34.     else
  35.     {
  36.         Console.WriteLine("\nПароль неверен!");
  37.         countFail++;
  38.     }
  39. } while (countFail<5);
  40. if(countFail!=10)
  41.     Console.WriteLine("Количество неверных бесплатных вводов завершено! Повторите попытку через сутки.");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement