һ - רҵ·ĵϷƽ̨

数据结构实验报告(实验3,实验4) - 百度文库

Դû ʱ䣺2025/5/30 16:30:15 loading ƪĵֻ
˵ݽԤݿܲȫҪĵҪݣwordʹáword΢ź:xxxxxxxQQxxxxxx ܸṩĵл֧½⡣

2Ҫͼ

벡Ϊ13нͼ

벡Ϊ5нͼ

ֱ벡Ϊ21-40нͼ

3Դ #include #include #include typedef struct{ int arrive,treat; }PA;

typedef struct queue{ PA data; struct queue *link;

}QE;

void Enqueue(QE **head,QE **tail,PA x) { QE *p; p=(QE*)malloc(sizeof(QE)); p->data=x; p->link=NULL; if(*head==NULL) *head=*tail=p; else { (*tail)->link=p; *tail=p; } }

int Dequeue(QE **head,QE **tail,PA *cp) { QE *p; p=*head; if(*head==NULL) return 1; *cp=(*head)->data; *head=(*head)->link; if(*head==NULL) *tail=NULL; free(p); return 0; }

void Outputqueue(QE *head) { while(head!=NULL){ printf(\ʱ䣺%d ʱ䣺%d\\n\ head=head->link; } }

void Initdata(PA *pa,int n) { int parr=0; int i; for(i=0;i

}

int main() { QE *head,*tail; PA *p,curr; int n,i,finish,nowtime,dwait,pwait; head=tail=NULL; while(1) { n=0; nowtime=dwait=pwait=0; printf(\벡1~20 0 :\\n\ scanf(\ if(n==0) return 0; if(n>20||n<0) continue; if((p=(PA*)malloc(n*sizeof(PA)))==NULL) { printf(\ڴ\\n\ return 0; } Initdata(p,n); for(i=0;i0) dwait+=p[i].arrive-nowtime; nowtime=p[i].arrive; Enqueue(&head,&tail,p[i++]); } Dequeue(&head,&tail,&curr); pwait+=nowtime-curr.arrive; finish=nowtime+curr.treat; while(i

? С

ڱʵУջṹͶнṹʵеӦáջṹӦõƥ⣬ջṹеġ㷨ÿһţ㽫ֱջȴƥͬţţ뵱ǰջͬͣƥ䣬ջųջıʽд꣬ջеȴƥԪʱδ꣬ջѿգڲƥкջͬʱʱ˵ȫƥ䡣⣬ע⵽һ⣬ڽջͽӲܵȿٵջƣܲ磬ڽջͽӲʱȽⷢ硣

ڶеʱΪҪУαṩĺrandom޷VCУ˰ٶѧϰVC¿ʹõĺsrandrandտʼʹõʱtimeӣȵsrand((unsigned)time(NULL))Ȼٵrandַ֣ɵ֣ͬԼΪڳʱ϶̣ͬʱɼʱʱͬɵͬɾsrandĵãֻʹrandͬʱɶֵͬ⡣

数据结构实验报告(实验3,实验4) - 百度文库.doc ĵWordĵصԣ㸴ơ༭ղغʹӡ
Ƽ
Copyright © 2012-2023 һ Ȩ | ϵ
:վز֪ʶȨݡϢ紫ȨתصƷַȨ,һ֪ͨǣǻἰʱɾ
ͷQQxxxxxx 䣺xxxxxx@qq.com
ICP2023013149
Top