-
2024-11-16 09:53:31
发布于:浙江
45阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
struct node{
int data;
node *next;
};
int n,m;
node *head,*p,*r;
int main(){
cin>>n>>m;
head=new node;
head->data=1;
head->next=NULL;
r=head;
for (int i=2;i<=n;i++){
p=new node;
p->data=i;
p->next=NULL;
r->next=p;
r=p;
}
r->next=head;
node *q=head;
for(int i=1;i<n;i++){
for(int j=1;j<m-1;j++){
q=q->next;
}
q->next=q->next->next;
q=q->next;
}
cout<<q->data;
return 0;
}
这里空空如也
有帮助,赞一个