Skip to content

Instantly share code, notes, and snippets.

@qjatn0120
Created September 8, 2022 17:17
Show Gist options
  • Save qjatn0120/2bc3534703131e1c6db0344e1d660bc4 to your computer and use it in GitHub Desktop.
Save qjatn0120/2bc3534703131e1c6db0344e1d660bc4 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
int t, n, ans[105];
int main(){
cin.tie(nullptr), ios::sync_with_stdio(false);
cin >> t;
while(t--){
cin >> n;
for(int i = 1; i <= n; i++) ans[i] = i;
for(int i = n - 2; i > 1; i -= 2) swap(ans[i - 1], ans[i]);
for(int i = 1; i <= n; i++) cout << ans[i] << " ";
cout << "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment