Advertisement
Guest User

5. Login

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