Advertisement
Sininerebane

Untitled

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