Advertisement
bonumopus

pass

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