Advertisement
Jouzef

Login

Sep 22nd, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 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 ConsoleApp60
  8. {
  9.     class Program
  10.     {
  11.         static void Main()
  12.         {
  13.             string User = Console.ReadLine();
  14.             string password = "";
  15.             int L = User.Length;
  16.  
  17.             for (int i = L - 1; i >= 0; i--)
  18.             {
  19.                 password += User[i];
  20.             }
  21.  
  22.             int temp = 0;
  23.             while (User != password)
  24.             {
  25.                 string testpass = Console.ReadLine();
  26.  
  27.                 if (testpass == password)
  28.                 {
  29.                     Console.WriteLine($"User {User} logged in.");
  30.                     break;
  31.                 }
  32.  
  33.                 if(testpass != password)
  34.                 {
  35.                     temp++;
  36.                     if (temp <= 3)
  37.                     {
  38.                         Console.WriteLine("Incorrect password. Try again.");
  39.                     }
  40.                     else
  41.                     {
  42.                         Console.WriteLine("User sunny blocked!");
  43.                     }
  44.                 }
  45.             }
  46.  
  47.             Console.Read();
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement