Advertisement
Sininerebane

Untitled

Sep 12th, 2023
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 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.                     tryCount--;
  30.                     Console.WriteLine($"У вас осталось - {tryCount}  попыток");
  31.                 }
  32.             }
  33.  
  34.             Console.Write("\n Возвращайтесь к нам в еще раз");
  35.             Console.ReadKey();
  36.            
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement