fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7. if(n%2==0)
  8. {
  9. int even=2;
  10. int odd = 1;
  11. for(int i=1;i<=n;i++)
  12. {
  13. if(i%2!=0)
  14. {
  15. cout << even << " " ;
  16. even += 2;
  17. }
  18. else
  19. {
  20. cout << odd << " ";
  21. odd += 2;
  22. }
  23. }
  24. cout << endl;
  25.  
  26. }
  27. else
  28. {
  29. cout << "impossible'" << endl;
  30. }
  31. return 0;
  32. }
Success #stdin #stdout 0.01s 5320KB
stdin
4
stdout
2 1 4 3