Advertisement
MustyElbow

passwordTryCount

Sep 30th, 2023
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 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 passwordTryCount
  8. {
  9.     internal class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int triesCount = 3;
  14.             string password = "12345";
  15.             string inputUser;
  16.  
  17.             for (int i = 0; i < triesCount; i++)
  18.             {
  19.                 Console.WriteLine("Введите пароль ");
  20.                 inputUser = Console.ReadLine();
  21.                 if (inputUser == password)
  22.                 {
  23.                     Console.WriteLine("Секретная фраза");
  24.                     break;
  25.                 }
  26.  
  27.                 else
  28.                 {
  29.                     Console.WriteLine("Введён неверный пароль");
  30.                     Console.WriteLine($"У вас осталось попыток " + (triesCount - i - 1));
  31.                 }
  32.             }
  33.  
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement