Advertisement
GPbl3YH

CSLight #11

Jan 27th, 2021 (edited)
625
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace CSLight
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string password = "qazwsxedc";
  14.             string userInput;
  15.             string secretMessage = "Доступ разрешён";
  16.             int maxTry = 3;
  17.  
  18.             for (int i = 1; i <= maxTry; i++)
  19.             {
  20.                 Console.Write($"Попытка #{i}: ");
  21.                 userInput = Console.ReadLine();
  22.  
  23.                 if (userInput == password)
  24.                 {
  25.                     Console.WriteLine("\n" + secretMessage + "\n");
  26.                     Console.ReadKey();
  27.                     break;
  28.                 }
  29.                 else if (userInput != password && i != maxTry)
  30.                 {
  31.                     Console.WriteLine("\nПовторите ввод!\n");
  32.                 }
  33.             }
  34.             Console.ReadKey();
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement