Advertisement
Guest User

Untitled

a guest
May 24th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3.  
  4. void repeatArray(double inputArray[], const int SIZE)
  5. {
  6.     std::cout << "inside repeatArray" << std::endl;
  7.     // creating a dynamically allocated sized array
  8.     double* newArray = new double[SIZE * 2];
  9.     for (int i = 0; i < SIZE; i++)
  10.     {
  11.         // since newArray is twice the size of the original array and repeated,
  12.         // the values found at inputArray[i] can be store at i and i + size
  13.         newArray[i] = inputArray[i];
  14.         std::cout << "this is at i: " << newArray[i] << std::endl;
  15.         newArray[i + SIZE] = inputArray[i];
  16.         std::cout << "this is at i+size: " << newArray[i + SIZE] << std::endl;
  17.     }
  18.     std::cout << "this is in newArray" << std::endl;
  19.     for (int i = 0; i < SIZE * 2; i++)
  20.     {
  21.         std::cout << newArray[i] << " ";
  22.     }
  23.     std::cout << std::endl;
  24.     // delete the array we created using "new"
  25.     delete[]newArray;
  26.     delete[]inputArray;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement