fork(1) download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n, p, x[100];
  8. cin >> n;
  9. for (size_t i = 0; i < n; i++)
  10. {
  11. cin >> x[i];
  12. }
  13. cout << "p = " << (p = n/2) << '\n';
  14. for (size_t j = 0; j < p / 2; j++)
  15. {
  16. swap(x[j], x[p - 1 - j]);
  17. swap(x[n - 1 - j], x[n - 1 - (p - 1 - j)]);
  18. }
  19. for (size_t j = 0; j < n; j++)
  20. {
  21. cout<<x[j]<<endl;
  22. }
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 3344KB
stdin
6
1
2
3
4
5
6
stdout
p = 3
3
2
1
6
5
4