📄 yuesefuhuan.txt
字号:
#include<stdio.h>
#include<stdlib.h>
struct Lnode
{ int number;
int password;
struct Lnode *next;
}Lnode,* p,*q,*head;
f(int n )
{int i;
for(i=1;i<=n;i++)
{ if(i==1)
{
head=p=(struct Lnode*)malloc(sizeof(struct Lnode));
if(p==0) return(0);
}
else
{
q=(struct Lnode*)malloc(sizeof(struct Lnode));
if(q==0) return(0);
p->next=q;
p=q;
}
printf("please enter the %d people's password:",i);
scanf("%d",&(p->password));
p->number=i;
}
p->next=head;
p=head;
}
g(int n,int m)
{int j,i;
for (j=1;j<=n;j++)
{
for(i=1;i<m;i++) p=p->next;
m=p->password;
printf("%d->",p->number);
p->number=p->next->number;
p->password=p->next->password;
q=p->next;
p->next=p->next->next;
free(q);
}
return 0;
}
main()
{ int n,i,m,j;
printf("please enter the number of people n:");
scanf("%d",&n);
f(n);
printf("please enter the number m:");
scanf("%d",&m);
g(n,m);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -