Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CSLight_Program_With_Password_HW
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.OutputEncoding = Encoding.UTF8;
- string password = "123456";
- string userInput;
- int tryCount = 3;
- for (int i = 1; i <= tryCount; i++)
- {
- Console.Write("Введите пароль: ");
- userInput = Console.ReadLine();
- if (userInput == password)
- {
- Console.WriteLine("Доступ к тайному сообщению разрешен!");
- break;
- }
- else if (i == 3)
- {
- Console.WriteLine("Доступ запрещен!");
- }
- else
- {
- Console.WriteLine($"У вас осталось попыток: {tryCount - i}");
- }
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement