笔试4/9
#include "stdafx.h"
#include <vector>
#include <iostream>
using namespace std;
vector<vector<int>>change(int num, vector<int> input)
{
vector<vector<int>> result(num);
for (int i = 0; i < num; i++)
{
vector<int> a;
for (int j = 0; j < input[i]; j++)
{
a.push_back(j + 1);
}
vector<int> a_out;
auto it = a.begin();
while (a.size() >= 2)
{
a_out.push_back(*it);
it = a.erase(it);
a.push_back(*it);
it = a.erase(it);
}
a_out.push_back(*it);
result[i] = a_out;
}
return result;
}
int main()
{
int num;
cin >> num;
vector<int> input(num);
for (int i = 0; i < num; i++)
{
cin >> input[i];
}
vector<vector<int>> result = change(num, input);
for (int i = 0; i < num; i++)
{
vector<int> output = result[i];
for (auto it = output.begin(); it != output.end(); it++)
{
cout << *it << " " ;
}
cout << endl;
}
return 0;
}