Advertisement
botgob

Untitled

Nov 22nd, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<ctime>
  4.  
  5. using namespace std;
  6.  
  7. void order(int& numberOne, int& numberTwo);
  8. void MoveIndex(int array1[8]);
  9.  
  10. int main() {
  11.  
  12. /*int numbers[5];
  13.  
  14. numbers[2] = 78;
  15. cin >> numbers[3];
  16. cout << */
  17.  
  18.  
  19. /*const int CAP = 4;
  20. double values[CAP];
  21. cout << "Input " << CAP << " double values" << endl;
  22. for ( int i = 0; i < CAP; i++)
  23. {
  24. cin >> values[i];
  25. cin.ignore();
  26.  
  27.  
  28. }
  29. cout << "The values you did input are: " << endl;
  30. for (int i = 0; i < CAP; i++)
  31. {
  32.  
  33. cout << values[i] << endl;
  34. }*/
  35.  
  36.  
  37.  
  38. /*int numbers[3]{ 10,20,30 }; *///initieringslista
  39.  
  40. /*int numbers[5]{};
  41.  
  42. numbers[3] = 58;
  43.  
  44. const int CAP = 6;
  45. string names[CAP]{ " " };
  46. names[2] = "Nisse";*/
  47.  
  48.  
  49.  
  50. srand((unsigned int)time(0));
  51.  
  52. const int CAP = 8;
  53. int numbers[CAP]{};
  54. int sum = 0;
  55. int amountOfEvenNrs = 0;
  56. int amountOfOddNrs = 0;
  57. int index = 0;
  58.  
  59.  
  60.  
  61.  
  62. for (int i = 0; i < CAP; i++) {
  63. numbers[i] = rand() % 11 + 10;
  64.  
  65. cout << index << ". " << numbers[i] << endl;
  66. sum += numbers[i];
  67. index++;
  68.  
  69. if (numbers[i] % 2 == 0) {
  70. amountOfEvenNrs++;
  71. } else {
  72. amountOfOddNrs++;
  73. }
  74.  
  75. }
  76.  
  77.  
  78.  
  79.  
  80. //cout << "Sum of numbers: " << sum << endl;
  81. //cout << "Amount of odd numbers: " << amountOfOddNrs << endl;
  82. //cout << "Amount of even numbers: " << amountOfEvenNrs << endl;
  83. //
  84.  
  85. //int nr1 = numbers[3];
  86. //int nr2 = numbers[5];
  87.  
  88. //order(nr1, nr2);
  89.  
  90. //cout << nr1 << endl << nr2 << endl;
  91. //cout << endl;
  92.  
  93. //
  94.  
  95. //for (int i = CAP-1; i >= 0; i--) {
  96. // cout << numbers[i] << endl;
  97.  
  98. //}
  99. MoveIndex(numbers);
  100. cout << "MoveIndex is called"<< endl;
  101. for (int i = 0; i < CAP; i++) {
  102. cout << numbers[i] << endl;
  103. }
  104.  
  105. getchar();
  106. return 0;
  107. }
  108.  
  109.  
  110.  
  111. void order(int& numberOne, int& numberTwo) {
  112.  
  113. int temp = 0;
  114.  
  115. temp = numberOne;
  116. numberOne = numberTwo;
  117. numberTwo = temp;
  118.  
  119. }
  120. void MoveIndex(int array1[8]) {
  121. int tempArray[8];
  122.  
  123. for (int i = 0; i < 8; i++) {
  124. if (i == 0) {
  125. tempArray[7] = array1[i];
  126. tempArray[i] = array1[i + 1];
  127. } else if (i < 7) {
  128. tempArray[i] = array1[i + 1];
  129. }
  130. }
  131. for (int i = 0; i < 8; i++) {
  132. array1[i] = tempArray[i];
  133. }
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement