fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long iint;
  4.  
  5. int main() {
  6. int n;
  7. cin >> n;
  8. for (int i = 1; i <= n; i++) {
  9. if (i % 2 != 0) {
  10. cout << i << " ";
  11. }
  12. }
  13. for (int i = 1; i <= n; i++) {
  14. if (i % 2 == 0) {
  15. cout << i << " ";
  16. }
  17. }
  18. }
Success #stdin #stdout 0.01s 5304KB
stdin
5
stdout
1 3 5 2 4