- 思路:
- 纯属数据结构中队列的应用,可以练练手。
- 具体代码如下:
#include <iostream>
#include <queue>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int num;
cin >> num;
queue<int> store;
for (int i = 1; i <= num; i++) {
store.push(i);
}
for (int i = 1; i <= num; i++) {
cout << store.front() << " ";
store.pop();
int temp = store.front();
store.pop();
store.push(temp);
}
cout << endl;
}
return 0;
}