Advertisement
DominikPasiut

Untitled

Jan 17th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.66 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int* flipArray(int input[], int n)
  5. {
  6.     int output[n];
  7.     int pos = 0;
  8.     for (int i = n-1; i >= 0; i--)
  9.     {
  10.         output[pos++] = input[i];
  11.     }
  12.     int* p = output;
  13.     for (int k = 0; k < n; k++)
  14.         cout << *p-k << endl << endl;
  15.     return p;
  16. }
  17.  
  18. int main()
  19. {
  20.     const int SIZE = 5;
  21.     int firstArray[SIZE];
  22.     for (int n = 0; n < SIZE; n++)
  23.     {
  24.         firstArray[n] = n+1;
  25.     }
  26.     int* a;
  27.     a = flipArray(firstArray, SIZE);
  28.     for (int j = 0; j < SIZE; j++)
  29.         cout << *a-j << endl;
  30.  
  31.     cout << endl;
  32.     cout << *a << '\t' << *a+1 << '\t' << *a+2;
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement