petyaminkova91

Untitled

Aug 1st, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _07_SafePasswordsGenerator
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int a = int.Parse(Console.ReadLine());
  10. int b = int.Parse(Console.ReadLine());
  11. int maxPasswordsCount = int.Parse(Console.ReadLine());
  12. int combinationsCounter = 0;
  13. bool hasReachedTheLimit = false;
  14.  
  15. for (char symbolA = (char)35; symbolA < 56; symbolA++)
  16. {
  17. for (char symbolB = (char)64; symbolB < 97; symbolB++)
  18. {
  19. for (int numberX = 1; numberX <= a; numberX++)
  20. {
  21. for (int numberY = 1; numberY <= b; numberY++)
  22. {
  23. Console.Write($"{(char)symbolA}{(char)symbolB}{numberX}{numberY}{(char)symbolB}{(char)symbolA}|");
  24. symbolA++;
  25. symbolB++;
  26.  
  27. combinationsCounter++;
  28.  
  29. if (combinationsCounter >= maxPasswordsCount)
  30. {
  31. hasReachedTheLimit = true;
  32. break;
  33. }
  34. if (numberY == b && numberX == a)
  35. {
  36. hasReachedTheLimit = true;
  37. break;
  38. }
  39. }
  40.  
  41. if (hasReachedTheLimit)
  42. {
  43. break;
  44. }
  45. if (symbolA > 56)
  46. {
  47. symbolA = (char)35;
  48. }
  49. if (symbolB > 97)
  50. {
  51. symbolB = (char)64;
  52. }
  53. }
  54. if (hasReachedTheLimit)
  55. {
  56. break;
  57. }
  58. }
  59. if (hasReachedTheLimit)
  60. {
  61. break;
  62. }
  63. }
  64.  
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment