题目连接:https://vjudge.net/problem/ZOJ-4032
思路:首先可以确定n-1条边,i与i+n相连 ,最后一条边n-1和3*n-4相连
code:
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int T;
scanf("%d",&T);
while(T--){
int n;
scanf("%d",&n);
if(n==2){
printf("0 2 1 3\n");
continue ;
}
for(int i=0;i<n-1;i++){
printf("%d %d ",i,n+i);
}
printf("%d %d",n-1,3*n-4);
puts("");
}
return 0;
}