Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _05.Login
- {
- class Program
- {
- static void Main(string[] args)
- {
- string userName = Console.ReadLine();
- int error = 0;
- int count = 0;
- bool login = true;
- while (login)
- {
- string password = Console.ReadLine();
- if (userName.Length != password.Length)
- {
- if (error == 3)
- {
- Console.WriteLine($"User {userName} blocked!");
- login = false;
- break;
- }
- Console.WriteLine("Incorrect password. Try again.");
- error++;
- }
- else
- {
- for (int i = 0; i < userName.Length; i++)
- {
- if (userName[i] == password[userName.Length - i - 1])
- {
- count++;
- if (count == userName.Length)
- {
- Console.WriteLine($"User {userName} logged in.");
- login = false;
- break;
- }
- }
- else
- {
- if (error == 3)
- {
- Console.WriteLine($"User {userName} blocked!");
- login = false;
- break;
- }
- Console.WriteLine("Incorrect password. Try again.");
- error++;
- count = 0;
- break;
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement