fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int n;
  7. int tab[1000];
  8. cin >> n;
  9. for(int i=0;i<n;i++) {
  10. cin >> tab[i];
  11. }
  12. for(int i=1;i<n;i+=2) {
  13. cout << tab[i] << " ";
  14. }
  15. for(int i=0;i<n;i+=2) {
  16. cout << tab[i] << " ";
  17. }
  18. cout << endl;
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 5280KB
stdin
5
1 3 4 5 7
stdout
3 5 1 4 7