Sininerebane

Untitled

Sep 27th, 2023
1,098
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 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.  
  13.             accessToMessage = "123456789";
  14.             tryCount = 3;
  15.  
  16.             for (int i = 0; i < tryCount; i++)
  17.             {
  18.                 Console.WriteLine("Введите свой пароль");
  19.                 password = Console.ReadLine();
  20.  
  21.                 if (password == accessToMessage)
  22.                 {
  23.                     Console.WriteLine("Вы читаете тайное сообщение");
  24.                     break;
  25.                 }
  26.                 else
  27.                 {
  28.                     Console.WriteLine("Вам в тайном сообщение отказано");
  29.                     Console.WriteLine($"У вас осталось - {tryCount - i - 1}  попыток");
  30.                 }
  31.             }
  32.  
  33.             Console.Write("\n Возвращайтесь к нам в еще раз");
  34.             Console.ReadKey();
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment