Advertisement
tsvetelinapasheva

Login

Mar 2nd, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Login
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string username = Console.ReadLine();
  14.             string password = Console.ReadLine();
  15.  
  16.             string reversedUsername = string.Empty;
  17.             char[] usernameCharArray = username.ToArray();
  18.  
  19.             for (int i = usernameCharArray.Length - 1; i >= 0; i--)
  20.             {
  21.                 reversedUsername += usernameCharArray[i];
  22.             }
  23.  
  24.             while (password != reversedUsername)
  25.             {
  26.                 Console.WriteLine($"Incorrect password. Try again.");
  27.                 password = Console.ReadLine();
  28.             }
  29.  
  30.             Console.WriteLine($"User {username} logged in.");
  31.  
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement