Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- void repeatArray(double inputArray[], const int SIZE)
- {
- std::cout << "inside repeatArray" << std::endl;
- // creating a dynamically allocated sized array
- double* newArray = new double[SIZE * 2];
- for (int i = 0; i < SIZE; i++)
- {
- // since newArray is twice the size of the original array and repeated,
- // the values found at inputArray[i] can be store at i and i + size
- newArray[i] = inputArray[i];
- std::cout << "this is at i: " << newArray[i] << std::endl;
- newArray[i + SIZE] = inputArray[i];
- std::cout << "this is at i+size: " << newArray[i + SIZE] << std::endl;
- }
- std::cout << "this is in newArray" << std::endl;
- for (int i = 0; i < SIZE * 2; i++)
- {
- std::cout << newArray[i] << " ";
- }
- std::cout << std::endl;
- // delete the array we created using "new"
- delete[]newArray;
- delete[]inputArray;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement