Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 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.  
  12. static void Main(string[] args)
  13.  
  14. {
  15.  
  16. string username = Console.ReadLine();
  17. string password = Console.ReadLine();
  18.  
  19.  
  20. char[] reverse = username.ToCharArray();
  21. Array.Reverse(reverse);
  22. string reversed = new string(reverse);
  23.  
  24.  
  25. if (reversed == password)
  26. {
  27. Console.WriteLine($"User {username} logged in.");
  28. }
  29.  
  30. else
  31. {
  32. for (int count = 0; count < 4; count++)
  33. {
  34. Console.WriteLine("Incorrect password. Try again.");
  35. password = Console.ReadLine();
  36.  
  37. if (reversed == password)
  38. {
  39. Console.WriteLine($"User {username} logged in."); break;
  40. }
  41.  
  42. else if (count >= 2)
  43. {
  44. Console.WriteLine($"User {username} blocked!"); break;
  45. }
  46. }
  47. }
  48.  
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement