Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<ctime>
- using namespace std;
- void order(int& numberOne, int& numberTwo);
- void MoveIndex(int array1[8]);
- int main() {
- /*int numbers[5];
- numbers[2] = 78;
- cin >> numbers[3];
- cout << */
- /*const int CAP = 4;
- double values[CAP];
- cout << "Input " << CAP << " double values" << endl;
- for ( int i = 0; i < CAP; i++)
- {
- cin >> values[i];
- cin.ignore();
- }
- cout << "The values you did input are: " << endl;
- for (int i = 0; i < CAP; i++)
- {
- cout << values[i] << endl;
- }*/
- /*int numbers[3]{ 10,20,30 }; *///initieringslista
- /*int numbers[5]{};
- numbers[3] = 58;
- const int CAP = 6;
- string names[CAP]{ " " };
- names[2] = "Nisse";*/
- srand((unsigned int)time(0));
- const int CAP = 8;
- int numbers[CAP]{};
- int sum = 0;
- int amountOfEvenNrs = 0;
- int amountOfOddNrs = 0;
- int index = 0;
- for (int i = 0; i < CAP; i++) {
- numbers[i] = rand() % 11 + 10;
- cout << index << ". " << numbers[i] << endl;
- sum += numbers[i];
- index++;
- if (numbers[i] % 2 == 0) {
- amountOfEvenNrs++;
- } else {
- amountOfOddNrs++;
- }
- }
- //cout << "Sum of numbers: " << sum << endl;
- //cout << "Amount of odd numbers: " << amountOfOddNrs << endl;
- //cout << "Amount of even numbers: " << amountOfEvenNrs << endl;
- //
- //int nr1 = numbers[3];
- //int nr2 = numbers[5];
- //order(nr1, nr2);
- //cout << nr1 << endl << nr2 << endl;
- //cout << endl;
- //
- //for (int i = CAP-1; i >= 0; i--) {
- // cout << numbers[i] << endl;
- //}
- MoveIndex(numbers);
- cout << "MoveIndex is called"<< endl;
- for (int i = 0; i < CAP; i++) {
- cout << numbers[i] << endl;
- }
- getchar();
- return 0;
- }
- void order(int& numberOne, int& numberTwo) {
- int temp = 0;
- temp = numberOne;
- numberOne = numberTwo;
- numberTwo = temp;
- }
- void MoveIndex(int array1[8]) {
- int tempArray[8];
- for (int i = 0; i < 8; i++) {
- if (i == 0) {
- tempArray[7] = array1[i];
- tempArray[i] = array1[i + 1];
- } else if (i < 7) {
- tempArray[i] = array1[i + 1];
- }
- }
- for (int i = 0; i < 8; i++) {
- array1[i] = tempArray[i];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement