Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string user = Console.ReadLine(); // Потребителят въвежда потребителското име.
- string password = ""; // Правим променлива за паролата, която ще я въведем чрез for- цикъл, който върти от последната буква към първата и добавя към този стринг.
- int counterEnter = 1; // Каунтерът трябва да е развен на 1, защото вече сме въвели 1 път някаква парола.
- for (int i = user.Length-1; i>=0 ; i--) // vurta ot poslednata do purviq simvol stringa koito e vkaran ot konzolata
- {
- password += user[i];
- }
- string input = Console.ReadLine(); // Вход, който потребителя започва да си въвежда паролата (ако си я знае :D)
- while (input != password)
- {
- if (counterEnter == 4) // Първо проверяваме дали това не е 4-тия опит
- {
- Console.WriteLine($"User {user} blocked!");
- break;
- }
- counterEnter++;
- Console.WriteLine($"Incorrect password. Try again.");
- input = Console.ReadLine();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement