📄 tc1.txt
字号:
#include "stdio.h"
#include "graphics.h"
#include "stdlib.h"
typedef struct LNode{
int num;
int data;
struct LNode *next;}LNode;
int i,j,n;
main()
{ int m,n;
LNode *q,*p,*T;
struct LNode *createList_L(int);
printf("初值:");
scanf("%d",&m);
printf("人数:");
scanf("%d",&n);
T=createList_L(n);
p=(struct LNode *)malloc(sizeof(LNode));
q=T;
p->next=q;
loop: while(p->num!=q->num)
{ for(i=1;i<m;i++)
{ q=q->next;p=p->next;}
m=q->data; n=q->num;
q=q->next;p->next=q;
printf("此次出列的号码:%d\n",n);
goto loop;
}
printf("此次出列的号码:%d\n",q->num);
}
struct LNode *createList_L(int n)
{ LNode *L;
struct LNode *p1,*p2;
L=NULL;
for(i=1;i<=n;i++)
{ p2=(struct LNode *)malloc(sizeof(LNode));
p2->num=i;
printf("序号:%d",i);
printf("密码:");scanf("%d",&p2->data);
if(i==1)
L=p1=p2;
else p1->next=p2;
p1=p2;
}
p1->next=L;
return(L) ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -