Advertisement
TheLegend12

Untitled

Sep 20th, 2023
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.99 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3.  
  4. *******************************************************************************/
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.  
  12. int a;
  13. int b;
  14. int c;
  15. int d;
  16. int res1;
  17. int res2;
  18. int res3;
  19. int operator1;
  20. int operator2;
  21. int operator3;
  22. int start;
  23. int endingVal;
  24. int counter;
  25.  
  26. cin >> start;
  27. cin >> endingVal;
  28.  
  29. for(a = 1; a <= 9; ++a){
  30. for(b = 1; b <= 9; ++b){
  31. for(c = 1; c <= 9; ++c){
  32. for(d = 1; d <= 9; ++d){
  33. for( operator1 = 1; operator1 <= 4; ++operator1 ){
  34. for(operator2 = 1; operator2 <= 4; ++operator2){
  35. for(operator3 = 1; operator3 <= 4; ++operator3){
  36. if (operator1 == 1){
  37. res1 = a + b;
  38. else if(operator1 == 2){
  39. res1 = a - b;
  40. else if(operator1 == 3){
  41. res1 = a / b;
  42. else if(operator1 == 4){
  43. res1 = a * b;
  44. }
  45. }
  46. }
  47. }
  48. if(operator2 == 1){
  49. res2 = res1 + c;
  50. }
  51. else if (operator2 == 2){
  52. res2 = res1 - c;
  53. }
  54. else if (operator2 == 3){
  55. res2 = res1 / c;
  56. }
  57. else if (operator2 == 4){
  58. res2 = res1 * c;
  59. }
  60. if (operator3 == 1){
  61. res3 = res2 + d;
  62. }
  63. else if(operator3 == 2){
  64. res3 = res2 - d;
  65. }
  66. else if(operator3 == 3){
  67. res3 = res2 / d;
  68. }
  69. else if(operator3 == 4){
  70. res3 = res2 * d;
  71. }
  72. if (res3 == 24){
  73. ++counter;
  74. if (counter >= start && counter <= endingVal){
  75. if (operator1 == 1){
  76. cout << a << " + " << b;
  77. }
  78. else if(operator1 == 2){
  79. cout << a << " - " << b;
  80. }
  81. else if(operator1 == 3){
  82. cout << a << " / " << b;
  83. }
  84. else if (operator1 == 4){
  85. cout << a << " * " << b;
  86. }
  87. if (operator2 == 1){
  88. cout << b << " + " << c;
  89. }
  90. else if (operator2 == 2){
  91. cout << b << " - " << c;
  92. }
  93. else if (operator2 == 3){
  94. cout << b << " / " << c;
  95. }
  96. else if (operator2 == 4){
  97. cout << b << " * " << c;
  98. }
  99. if(operator3 == 1){
  100. cout << c << " + " << d;
  101. }
  102. else if (operator3 == 2){
  103. cout << c << " - " << d;
  104. }
  105. else if(operator3 == 3){
  106. cout << c << " / " << d;
  107. }
  108. else if(operator3 == 4){
  109. cout << c << " * " << d;
  110. }
  111. cout << " = " << res3;
  112. cout << endl;
  113. }
  114.  
  115. }
  116. }
  117. }
  118. }
  119. }
  120.  
  121. }
  122. }
  123. }
  124.  
  125.  
  126. return 0;
  127. }
  128.  
  129.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement