fork download
  1. #include<iostream>
  2. #include<vector>
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8. int n;
  9. cin >> n;
  10. int* arr = new int [n];
  11. for (int i = 0; i < n; i++)
  12. {
  13. cin >> arr[i];
  14. }
  15.  
  16. for (int i = 0; i < n / 2; i++)
  17. {
  18. int t = arr[i];
  19. arr[i] = arr[n - 1 - i];
  20. arr[n - 1 - i] = t;
  21. }
  22.  
  23. for (int i = 0; i < n; i++)
  24. {
  25. cout << arr[i] << " ";
  26. }
  27. }
Success #stdin #stdout 0s 5268KB
stdin
2
1
2
stdout
2 1