Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- static class StringHelper
- {
- public static string ReverseString(string s)
- {
- char[] arr = s.ToCharArray();
- Array.Reverse(arr);
- return new string(arr);
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- string username = Console.ReadLine();
- int possibleTryis = 4;
- int block = 0;
- for (int i = 0; i < possibleTryis; i++)
- {
- string password = Console.ReadLine();
- block++;
- if (password == (StringHelper.ReverseString($"{username}")))
- {
- Console.WriteLine($"User {username} logged in.");
- break;
- }
- else if (block >= 4)
- {
- Console.WriteLine($"User {username} blocked!");
- break;
- }
- else if (password != "Mecho")
- {
- Console.WriteLine("Incorrect password. Try again.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement