小组徐瑞雄

我和我的

dsfsdfdsfds.

dgdfg

image

鬼地方高浮雕

#include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
struct node *next;
};
int main()
{
int n,m,i;
struct node *head,*p,*t;
head=(struct node *)malloc(sizeof(struct node ));
head->next=NULL;
t=head;
head->data=1;
scanf("%d %d",&n,&m);
for(i=2;i<=n;i++)
{
p=(struct node *)malloc(sizeof(struct node));
p->data=i;
p->next=NULL;
t->next=p;
t=p;
}
t->next=head;
p=t;
while(p->next!=p)
{
for(i=0;i<m-1;i++)p=p->next;
p->next=p->next->next;
}
printf("%d\n",p->data);
return 0;
}

posted @ 2021-10-15 22:47  pc_5kill  阅读(40)  评论(0)    收藏  举报