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)//100/100
- {
- string userName = Console.ReadLine();//username
- char[] correctPasswordChars = new char[userName.Length];//count username characters
- for (int i = 0; i < userName.Length; i++)//loop with count characters of username
- {
- correctPasswordChars[i] = userName[(userName.Length - 1) - i]; //reverse username characters
- }
- string correctPassword = new string(correctPasswordChars); //generate correct password
- for (int i = 0; i < 4; i++)
- {
- string password = Console.ReadLine();
- if (password == correctPassword)
- {
- Console.WriteLine($"User {userName} logged in.");
- break;
- }
- else if (i >= 3)
- {
- Console.WriteLine($"User {userName} blocked!");
- }
- else
- {
- Console.WriteLine("Incorrect password. Try again.");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement