```cpp
#include<iostream>
using namespace std;
struct node
{int data;
node *next;
};
node *head,*r,*p;
int main()
{head=new node;
r=new node;
p=new node;
p->data=1;
head=p;
head->next=0;
r=p;
int n;
int m;
cin>>n>>m;
for(int i=2;i<=n;i++)
{
p=new node;
p->data=i;
r->next=p;
r=p;
p->next=0;
}
r->next=head;
r=head;
int k=0;
for(int i=1;i<=n;i++)
{k++;
r=r->next;
if(k==m-2)
{
cout<<r->next->data<<" " ;
r->next=r->next->next;
k=0;
}
r=r->next;
}
return 0;
}
```
by hehe123313 @ 2023-09-20 22:55:30
一直有个问题,为什么你们不用队列
by yjx1234 @ 2023-09-21 19:42:33