Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string username = Console.ReadLine();
- var password = new string(username.ToCharArray().Reverse().ToArray());
- int attempts = 0;
- for (int i = 1; i <= 3; i++)
- {
- string guess = Console.ReadLine();
- if (guess != password)
- {
- Console.WriteLine("Incorrect password. Try again.");
- attempts++;
- if (attempts == 3)
- {
- Console.WriteLine($"User {username} blocked!");
- }
- }
- else if (guess == password)
- {
- Console.WriteLine($"User {username} logged in.");
- break;
- }
- }
- //while (true)
- //{
- // string guess = Console.ReadLine();
- // if (guess == password)
- // {
- // Console.WriteLine($"User {username} logged in.");
- // return;
- // }
- // else if (guess != password)
- // {
- // Console.WriteLine("Incorrect password. Try again.");
- // attempts++;
- // if (attempts == 3)
- // {
- // Console.WriteLine($"User {username} blocked!");
- // break;
- // }
- // }
- //}
Advertisement
Add Comment
Please, Sign In to add comment