📄 004.txt
字号:
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
typedef struct Data
{
int no;
int password;
};
typedef struct list
{
struct Data data;
struct list *next;
};
int num,m,i,j,l;
list *head,*tail,*p,*q,*pt,*pr,*pir;
void Input()
{
printf("Enter the total num =");
scanf("%d",&num);
printf("\nEnter the limt m=");
scanf("%d",&m);
if(num==0||m==0)
{
printf("Sorry ,there is no record in the queue!");
exit(0);
}
p=head=tail= (list *)malloc(sizeof(list));
p->data.no=1;
p->data.password=random(50)+1;
tail->next=head;
printf("\nNo-------------password");
printf("\n1\t\t%d",p->data.password);
for(i=2;i<=num;i++)
{
p=(list *)malloc(sizeof(list));
p->data.no=i;
p->data.password=random(50)+2;
printf("\n%d\t\t",i);
printf("%d",p->data.password);
delay(200);
p->next=head;
tail->next=p;
tail=p;
}
printf("\n\n");
}
void Process()
{
pr=tail->next;
j=1;
gotoxy(37,5);
printf("Out order NO------------its password\n");
while(num!=0)
{
l++;
while(j!=m-1)
{
j++;
pr=pr->next;
}
pt=pr->next;
pr->next=pt->next;
pr=pr->next;
gotoxy(36,5+l);
printf("\t%d\t\t\t%d\n",pt->data.no,pt->data.password);
delay(100);
num--;
j=1;
m=pt->data.password;
if(m>=num)
m=m-(m/num)*num;
free(pt);
}
}
void main()
{
clrscr();
Input();
Process();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -