AdemDev

Программа под паролем

Aug 31st, 2023
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp
  4. {
  5. internal class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string password = "0000";
  10. int attemptsCount = 3;
  11. string secretMessage = "Секретное сообщение";
  12.  
  13. for (int i = 1; i <= attemptsCount; i++)
  14. {
  15. Console.Write("Введите пароль: ");
  16. string userInput = Console.ReadLine();
  17.  
  18. if (userInput == password)
  19. {
  20. Console.WriteLine($"Пароль верный!\n{secretMessage}");
  21. break;
  22. }
  23. else
  24. {
  25. int remainAttemptsCount = attemptsCount - i;
  26. Console.WriteLine($"Пароль неверный!\nОсталось попыток: {remainAttemptsCount}\n");
  27. }
  28. }
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment