Sininerebane

Untitled

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