资源预览内容
第1页 / 共6页
第2页 / 共6页
第3页 / 共6页
第4页 / 共6页
第5页 / 共6页
第6页 / 共6页
亲,该文档总共6页全部预览完了,如果喜欢就下载吧!
资源描述
#include#include#include#define tcs 2 /停车场内最多停车数#define price 0.02/停车内停车的单价(每分钟)typedef struct tsint tx;/停车的时刻 小时int tf;/停车的时刻 分钟ts1;typedef struct cj char num10;/车牌照 ts1 d; ts1 l;cn;typedef struct Cjcn *stacktcs+1; int top;Car;typedef struct carcn *data; struct car *next;QueueNode;typedef struct NodeQueueNode *head; QueueNode *rear;LCar;void Tc(Car *); void Bd(LCar *);void D(Car *,LCar *); void L(Car *,Car *,LCar *);void Lb(Car,LCar); void Sc(cn *c,int cw) /输出信息 int d1,d2,l1,l2; printf(n车辆离开的时间:); scanf(%d:%d,&(c-l.tx),&(c-l.tf); printf(n离开车辆的车牌号为:); puts(c-num); printf(n其到达时间为: %d:%d,c-d.tx,c-d.tf); printf(离开时间为: %d:%d,c-l.tx,c-l.tf); d1=c-d.tx; d2=c-d.tf; l1=c-l.tx; l2=c-l.tf; printf(n应交费用为: %2.1f元,(l1-d1)*60+(l2-d2)*price); free(c);void D(Car *Enter,LCar *W) cn *p; QueueNode *t; p=(cn *)malloc(sizeof(cn); flushall();printf(n请输入车牌号(例:辽A1234):n); gets(p-num); if(Enter-toptop+;printf(n车辆在车场第%d位置.,Enter-top); printf(n车辆到达时间:整时=24, 分钟d.tx),&(p-d.tf); Enter-stackEnter-top=p; else printf(n该车须在便道等待!有车位时进入车场n); t=(QueueNode *)malloc(sizeof(QueueNode); t-data=p; t-next=NULL; W-rear-next=t; W-rear=t; void L(Car *Enter,Car *Temp,LCar *W) int cw; cn *p,*t; QueueNode *q; if(Enter-top0) while(1) printf(n请输入车在车场的位置/1-%d/:,Enter-top); scanf(%d,&cw); if(cw=1&cwtop) break;while(Enter-topcw) Temp-top+;Temp-stackTemp-top=Enter-stackEnter-top; Enter-stackEnter-top=NULL; Enter-top-; p=Enter-stackEnter-top; Enter-stackEnter-top=NULL; Enter-top-;while(Temp-top=1) Enter-top+;Enter-stackEnter-top=Temp-stackTemp-top; Temp-stackTemp-top=NULL; Temp-top-;Sc(p,cw);if(W-head!=W-rear)&Enter-tophead-next; t=q-data; Enter-top+;printf(n便道的%s号车进入车场第%d位置.,t-num,Enter-top); printf(n请输入%s号车进入车场的时间:);scanf(%d:%d,&(t-d.tx),&(t-d.tf); W-head-next=q-next; if(q=W-rear) W-rear=W-head; Enter-stackEnter-top=t; free(q);else printf(n便道里没有车.n);else printf(n车场里没有车.); void Lb1(Car *S) int i;if(S-top0)printf(n车场:);printf(n 位置到达时间 车牌号n);for(i=1;itop;i+)printf( %d ,i);printf( %d:%d ,S-stacki-d.tx,S-stacki-d.tf);puts(S-stacki-num);else printf(n车场里没有车);void Lb2(LCar *W) QueueNode *p;p=W-head-next;if(W-head!=W-rear)printf(n等待车辆的号码为:);while(p!=NULL)puts(p-data-num);p=p-next;else printf(n便道里没有车.);void Lb(Car S,LCar W)int flag,tag;flag=1; while(flag)printf(n请选择 1|2|3:n);printf(n 1.车场列表n 2.便道列表n 3.返回主菜单n);while(1) scanf(%d,&tag);if(tag=1|tag=1&chtop=0; for(i=0;istacks-top=NULL;void Bd(LCar *Q)Q-head=(QueueNode *)malloc(sizeof(QueueNode); if(Q-head!=NULL) Q-head-next=NULL; Q-rear=Q-head;
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号