Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Globalization;
- using System.Linq;
- class LogIn
- {
- static void Main()
- {
- string userName = Console.ReadLine();
- char [] userArray = userName.ToCharArray();
- var count = 1;
- for (int i = 0; i<userArray.Length/2; i++)
- {
- char a = userArray[i];
- char b = userArray[userArray.Length - i - 1];
- userArray[i] = b;
- userArray[userArray.Length - i - 1] = a;
- }
- string password = Console.ReadLine();
- char[] passwordArray = password.ToCharArray();
- while (!passwordArray.SequenceEqual( userArray) && count <= 3)
- {
- Console.WriteLine("Incorrect password. Try again.");
- count++;
- password = Console.ReadLine();
- passwordArray = password.ToCharArray();
- }
- if (!passwordArray.SequenceEqual(userArray) && count==4)
- {
- Console.WriteLine($"User {userName} blocked!");
- }
- if (passwordArray.SequenceEqual(userArray))
- {
- Console.WriteLine($"User {userName} logged in.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment