Guest User

Untitled

a guest
Sep 24th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 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 Login
  10. {
  11. static void Main(string[] args)
  12. {
  13. string username = Console.ReadLine();
  14. int counter = 0;
  15.  
  16. char[] passwordChar = username.ToCharArray();
  17.  
  18. for (int i = 0; i < passwordChar.Length / 2; i++)
  19. {
  20. char temp = passwordChar[i];
  21. passwordChar[i] = passwordChar[passwordChar.Length - i - 1];
  22. passwordChar[passwordChar.Length - i - 1] = temp;
  23. }
  24. string password = new string(passwordChar);
  25.  
  26. while(true)
  27. {
  28. if (Console.ReadLine() == password)
  29. {
  30. Console.WriteLine($"User {username} logged in.");
  31. break;
  32. }
  33. else if(counter >= 3)
  34. {
  35. Console.WriteLine($"User {username} blocked!");
  36. break;
  37. }
  38. else
  39. {
  40. Console.WriteLine("Incorrect password. Try again.");
  41. counter++;
  42. }
  43. }
  44. }
  45. }
  46. }
Add Comment
Please, Sign In to add comment