Advertisement
Cataykus

Untitled

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