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 Login
- {
- class Login
- {
- static void Main(string[] args)
- {
- string username = Console.ReadLine();
- int counter = 0;
- char[] passwordChar = username.ToCharArray();
- for (int i = 0; i < passwordChar.Length / 2; i++)
- {
- char temp = passwordChar[i];
- passwordChar[i] = passwordChar[passwordChar.Length - i - 1];
- passwordChar[passwordChar.Length - i - 1] = temp;
- }
- string password = new string(passwordChar);
- while(true)
- {
- if (Console.ReadLine() == password)
- {
- Console.WriteLine($"User {username} logged in.");
- break;
- }
- else if(counter >= 3)
- {
- Console.WriteLine($"User {username} blocked!");
- break;
- }
- else
- {
- Console.WriteLine("Incorrect password. Try again.");
- counter++;
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment