Advertisement
Rodunskiy

Untitled

May 8th, 2024
532
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CSLight
  4. {
  5.     public class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string password = "12345";
  10.             string secretMessage = "Hello";
  11.             string passwordTry;
  12.             int numberAttempts = 3;
  13.             bool isWorking = true;
  14.  
  15.             while (isWorking)
  16.             {
  17.                 for (int i = 0; i < numberAttempts; i++)
  18.                 {
  19.                     Console.Write("Введите пароль:");
  20.                     passwordTry = Console.ReadLine();
  21.  
  22.                     if (passwordTry == password)
  23.                     {
  24.                         Console.WriteLine(secretMessage);
  25.                         break;
  26.                     }
  27.                     else
  28.                     {
  29.                         Console.WriteLine("Неверный пароль!");                      
  30.                     }
  31.                 }
  32.  
  33.                 isWorking = false;
  34.             }
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement