fork download
  1. #include<iostream>
  2. #include<queue>
  3. using namespace std;
  4.  
  5.  
  6. int main() {
  7. int n;
  8. cin >> n; // 1 to 2e5
  9.  
  10. queue<int> q;
  11.  
  12. for(int i = 1; i <= n; i++) {
  13. q.push(i);
  14. }
  15.  
  16. while(!q.empty()) {
  17. q.push(q.front());
  18. q.pop();
  19. cout << q.front() << ' ';
  20. q.pop();
  21. }
  22. cout << '\n';
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0.01s 5324KB
stdin
7
stdout
2 4 6 1 5 3 7