Advertisement
Sininerebane

Untitled

Sep 18th, 2023
1,347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | Software | 0 0
  1. namespace SecretMessage
  2. {
  3.     internal class Program
  4.     {
  5.         static void Main(string[] args)
  6.         {
  7.             Console.OutputEncoding = Encoding.UTF8;
  8.  
  9.             string password;
  10.             string accessToMessage;
  11.             int tryCount;
  12.             int tryNumber;
  13.  
  14.             accessToMessage = "123456789";
  15.             tryCount = 3;
  16.  
  17.             for (int i = 0; i < tryCount; i++)
  18.             {
  19.                 Console.WriteLine("Введите свой пароль");
  20.                 password = Console.ReadLine();
  21.  
  22.                 if (password == accessToMessage)
  23.                 {
  24.                     Console.WriteLine("Вы читаете тайное сообщение");
  25.                     break;
  26.                 }
  27.                 else
  28.                 {
  29.                     Console.WriteLine("Вам в тайном сообщение отказано");
  30.                     tryNumber = tryCount - i - 1;
  31.  
  32.                     Console.WriteLine($"У вас осталось - {tryNumber}  попыток");
  33.                 }
  34.             }
  35.  
  36.             Console.Write("\n Возвращайтесь к нам в еще раз");
  37.             Console.ReadKey();
  38.            
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement