Advertisement
SaNik74

program with password

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