Advertisement
AziLif

Программа под паролем

Jun 4th, 2024 (edited)
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string password = "кри_21";
  10.             string userInput;
  11.            
  12.             int numberAttempts = 2;
  13.             int completingAttempts = 0;
  14.  
  15.             Console.WriteLine("Для получения секрета введите пароль!");
  16.  
  17.             for (int i = numberAttempts; i >= completingAttempts; i--)
  18.             {
  19.                 userInput = Console.ReadLine();
  20.  
  21.                 if (userInput != password)
  22.                 {
  23.                     Console.WriteLine($"Пароль не верный. Осталось {i} попыток.");
  24.                    
  25.                     if (i == 0 )
  26.                     {
  27.                         Console.WriteLine("Пароль был - кри_21");
  28.                     }
  29.                 }
  30.                 else if (userInput == password)
  31.                 {
  32.                     Console.WriteLine("Доступ открыт. Секрет - бергамот - это сморщенный лимон");
  33.                     break;
  34.                 }
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement