Spocoman

05. Login

Jan 12th, 2022
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace Login
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string user = Console.ReadLine();
  11.             string pass = string.Empty;
  12.             bool isPass = false;
  13.  
  14.             for (int i = user.Length - 1; i >= 0; i--)
  15.             {
  16.                 pass += user[i];
  17.             }
  18.  
  19.             for (int i = 0; i < 3; i++)
  20.             {
  21.                 if (pass == Console.ReadLine())
  22.                 {
  23.                     Console.WriteLine($"User {user} logged in.");
  24.                     isPass = true;
  25.                     break;
  26.                 }
  27.                 Console.WriteLine("Incorrect password. Try again.");
  28.             }
  29.  
  30.             if (!isPass)
  31.             {
  32.                 Console.WriteLine(pass == Console.ReadLine() ? $"User {user} logged in." : $"User {user} blocked!");
  33.             }
  34.         }
  35.     }
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment