silvana1303

login

Jun 19th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Threading;
  6.  
  7. namespace ConsoleApp1
  8. {
  9.     class Exam
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             char[] username = Console.ReadLine().ToCharArray();
  14.  
  15.             char[] reverse = username.Reverse().ToArray();
  16.  
  17.             int count = 0;
  18.  
  19.             while (count < 3)
  20.             {
  21.                 count++;
  22.                 char[] tryPass = Console.ReadLine().ToCharArray();
  23.  
  24.                 if (string.Join("", tryPass) == string.Join("", reverse))
  25.                 {
  26.                     Console.WriteLine($"User {string.Join("", username)} logged in.");
  27.                     return;
  28.                 }
  29.                 else
  30.                 {
  31.                     Console.WriteLine("Incorrect password. Try again.");
  32.                 }
  33.             }
  34.  
  35.             Console.WriteLine($"User {string.Join("", username)} blocked!");
  36.         }
  37.     }
  38. }
Add Comment
Please, Sign In to add comment