fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define vec vector<int>
  5. int main() {
  6. int n,f=1;
  7. cin >> n;
  8. deque<int> d;
  9. while (n--) {
  10. int x;
  11. cin >> x;
  12. if (f) {
  13. d.push_back(x);
  14. f=0;
  15. }
  16. else {
  17. d.push_front(x);
  18. f=1;
  19. }
  20. }
  21. for (int i=0;i<d.size();i++) {
  22. if (i==d.size()-1) {
  23. cout<<d[i];
  24. }
  25. else {
  26. cout<<d[i]<<" ";
  27. }
  28. }
  29. }
Success #stdin #stdout 0s 5300KB
stdin
4
1 2 3 4
stdout
4 2 1 3