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