Advertisement
farmi

Untitled

Feb 3rd, 2023
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <windows.h>
  4.  
  5. using namespace std;
  6. int arraySize;
  7.  
  8. void optionOne(int n) {
  9. int* array = new int[n];
  10. int num = 1;
  11. for (int i=0; i < n; i++) {
  12. if (num == 4) {
  13. num = 1;
  14. array[i] = num;
  15. }
  16. else {
  17. array[i] = num;
  18. }
  19. cout << array[i] << endl;
  20. num++;
  21. }
  22. }
  23.  
  24. void optionTwo(int n)
  25. {
  26. int* array = new int[n];
  27. int num = 1;
  28. for (int i = 0; i < n; i++) {
  29.  
  30. if (num > 32) {
  31. num = 1;
  32. cout << num << endl;
  33. }
  34. else {
  35. cout << num << endl;
  36. }
  37. num = num * 2;
  38. }
  39. }
  40.  
  41. void optionThree(int n) {
  42. int* array = new int[n];
  43. int k = 0;
  44. int l = 1;
  45. for (int i = 1; i <= n; i++) {
  46. for (int j = 0; j <= k; j++) {
  47.  
  48. array[i - 1] = l;
  49. //cout << i << " " << tablica << " " << l << endl;
  50. l = l * 2;
  51. i++;
  52. }
  53. i--;
  54. k++;
  55. l = 1;
  56. }
  57.  
  58. for (int i = 0; i < n; i++) {
  59. cout << array[i] << endl;
  60. }
  61.  
  62. }
  63.  
  64. void optionFour(int n) {
  65. int* array = new int[n];
  66. int num = 1;
  67. array[0] = num;
  68. cout << array[0] << endl;
  69. for (int i = 1; i <= n; i++) {
  70. array[i] = num;
  71. num *= 2;
  72. cout << array[i] << endl;
  73. }
  74. }
  75.  
  76. void optionFive(int n) {
  77. int* array = new int[n];
  78. for (int i = 0; i < n; i++) {
  79. if (i == 0 || i % 4 == 0) {
  80. cout << "A" << endl ;
  81. }
  82. else if(i == 1 || i % 4 == 1) {
  83. cout << "C" << endl ;
  84. }
  85. else if (i == 2 || i % 4 == 2) {
  86. cout << "E" << endl ;
  87. }
  88. else if (i == 3 || i % 4 == 3) {
  89. cout << "F" << endl ;
  90. }
  91. }
  92. }
  93.  
  94. void optionSix(int n) {
  95. int* array = new int[n];
  96. for (int i = 0; i < n; i++) {
  97. if (i == 0 || i == 7 || i % 8 == 0 || i % 8 == 7) {
  98. cout << "A" << endl;
  99. }
  100. else if (i == 1 || i == 6 || i % 8 == 1 || i % 8 == 6) {
  101. cout << "C" << endl;
  102. }
  103. else if (i == 2 || i == 5 || i % 8 == 2 || i % 8 == 5) {
  104. cout << "E" << endl;
  105. }
  106. else if (i == 3 || i == 4 || i % 8 == 3 || i % 8 == 4) {
  107. cout << "F" << endl;
  108. }
  109. }
  110. }
  111.  
  112. void optionSeven(int n) {
  113. int* array = new int[n];
  114. int i;
  115. double a, b, iFloat;
  116. // iFloat = i;
  117. cout << endl << "Type a: ";
  118. cin >> a;
  119. cout << endl << "Type b: ";
  120. cin >> b;
  121.  
  122. if (i % 2 == 1) {
  123. (cbrt(fabs(a + b + iFloat))) / (a - b);
  124. }
  125. else {
  126. sqrt(pow(a, 2) + pow(b, 2) + i);
  127. }
  128.  
  129.  
  130. }
  131. /*
  132. int main()
  133. {
  134. while (1) {
  135. cout << "Type size of array: ";
  136. cin >> arraySize;
  137.  
  138. int choose;
  139. cout << endl << "Choose type of filling method :" << endl;
  140. cout << "1. 1 2 3 1 2 3 1 2 3 ..." << endl;
  141. cout << "2. 1 2 4 8 16 32 1 2 4 8 16 32 1 2 4 8 16 32 ..." << endl;
  142. cout << "3. 1 1 2 1 2 4 1 2 4 8 1 2 4 8 16 ..." << endl;
  143. cout << "4. 1 1 2 4 8 16 32 64 128 ..." << endl;
  144. cout << "5. A C E F A C E F A C E F ..." << endl;
  145. cout << "6. A C E F F E C A A C E F F E C A A C E F F E C A ..." << endl;
  146.  
  147. cout << "Option: ";
  148. cin >> choose;
  149.  
  150. switch (choose) {
  151. case 1:
  152. optionOne(arraySize);
  153. break;
  154. case 2:
  155. optionTwo(arraySize);
  156. break;
  157. case 3:
  158. optionThree(arraySize);
  159. break;
  160. case 4:
  161. optionFour(arraySize);
  162. break;
  163. case 5:
  164. optionFive(arraySize);
  165. break;
  166. case 6:
  167. optionSix(arraySize);
  168. break;
  169. case 7:
  170. optionSeven(arraySize);
  171. break;
  172. }
  173. }
  174. }
  175.  
  176.  
  177. */
  178.  
  179.  
  180.  
  181.  
  182.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement