Advertisement
VoVfe

Untitled

Feb 24th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. static void Main(string[] args)
  2.         {
  3.             string password = "пирог";
  4.             int inputAttempts = 3;
  5.             string userInput;
  6.  
  7.             for(int i = 0; i < inputAttempts; i++)
  8.             {
  9.                 Console.Write("Введите пароль, чтобы получить доступ к серверу:");
  10.                 userInput = Console.ReadLine();
  11.  
  12.                 if (password == userInput)
  13.                 {
  14.                     Console.Write("Доступ получен!");
  15.                     Console.ReadKey();
  16.                     break;
  17.                 }
  18.  
  19.                 else
  20.                 {
  21.                     Console.WriteLine($"У вас осталось {inputAttempts - i - 1} попытки");
  22.                 }
  23.             }
  24.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement