Advertisement
Guest User

Untitled

a guest
Sep 21st, 2018
563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Login
  4. {
  5. public class Program
  6. {
  7. public static void Main(string[] args)
  8. {
  9. string username = Console.ReadLine();
  10. int counter = 0;
  11. char[] passwordChar = username.ToCharArray();
  12. Array.Reverse(passwordChar);
  13.  
  14. string password = new string(passwordChar);
  15. while(true)
  16. {
  17. if (Console.ReadLine() == password)
  18. {
  19. Console.WriteLine($"User {username} logged in.");
  20. break;
  21. }
  22. else if (counter >= 3)
  23. {
  24. Console.WriteLine($"User {username} blocked!");
  25. break;
  26. }
  27. else
  28. {
  29. Console.WriteLine("Incorrect password. Try again.");
  30. counter++;
  31. }
  32. }
  33.  
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement