思路如下:题目很好理解(但是有坑,在报数报完一轮的时候才看队伍里有几个人);用链表来写思路会简单很多;
代码如下:
#include<bits/stdc++.h>
using namespace std;
struct node
{
int i;
node *next;
};
void del(node *a,node *b)
{
node *temp;
temp=a->next;
cout<<temp->i;
free(temp);
a->next=b;
}
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
if(n==1)
{
cout<<"1"<<endl;
continue;
}
else if(n==2)
{
cout<<"1"<<" "<<"2"<<endl;
continue;
}
else if(n==3)
{
cout<<"1"<<" "<<"2"<<" "<<"3"<<endl;
continue;
}
node *head,*p;
p&