已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
#include#include#define stacksize 2 /车站/容量/typedef struct Snode int number; float int_time2; float bian_time2;record;typedef struct record *base; record *top; int size;Stack;/typedef struct Qnode int number; float int_time2; struct Qnode *next;Qnode,*Queue;typedef struct Queue front; Queue rear;Linkqueue;void xunhuan(Stack L,Linkqueue Q);void jixu(Stack L,Linkqueue Q);/void InitStack(Stack &L) /堆栈操作 L.base=(record*)malloc(sizeof(Snode)*stacksize); if(!L.base) exit(0); L.top=L.base; L.size=stacksize;/void input(Stack &L,record h) *L.top+=h; /Snode output(Stack &L,record &e) e=*-L.top; return e; int Stackman(Stack L) if(L.top-L.base=L.size) return 0; else return 1;int StackEmpty(Stack L) if(L.base=L.top) return 0; else return 1;/void Initque(Linkqueue &Q) /队列操作 Q.front=Q.rear=(Queue)malloc(sizeof(Qnode); if(!Q.front) exit(0); Q.front-next=NULL;/void enqueue(Linkqueue &Q,int number,float time) Queue q; printf(停车场已满,请将车辆停入便道!n); q=(Queue)malloc(sizeof(Qnode); q-int_time0=time0; q-int_time1=time1; q-number=number; q-next=NULL; Q.rear-next=q; Q.rear=q; /void outqueue(Linkqueue &Q,Queue &e) /此处有点问题? / Qnode *q; /q=(Queue)malloc(sizeof(Qnode); e=Q.front-next; / Q.front-next=q-next;/delete q; Q.front-next=Q.front-next-next; if(Q.rear=e) Q.front=Q.rear; / Q.front=NULL; int QEmpty(Linkqueue Q) if(Q.rear=Q.front) return 0; else return 1;/ /停车场管理操作/void jixu(Stack L,Linkqueue Q)int n; fflush(stdin); scanf(%d,&n);switch(n)case 1:printf(nn);xunhuan(L,Q); break;case 2:printf(*退出管理系统*n); break;default:printf(n输入错误,请重新输入: );jixu(L,Q);break;void jiaofei(float time,float time1,float time2) /缴费操作 float data1,data2;double money;if(time20!=0&time21!=0) data2=(time10-time20-1)*60+60-time21+time11;elsedata2=0;data1=(time0-time10-1)*60+60-time11+time1;/printf(进入车场时间%f,退出车场时间%fn,time11,time1);printf(你的停车时间为%lf小时 ,在便道停留时间%f小时n,data1/60,data2/60); money=data1/60*5.0+data2/60*2.0; printf(请交纳%lf元n,money); /* if(data160.0&data1120.0)printf(请交纳20元。);*/void leave(Stack &L,Linkqueue &Q,int number,float time) /汽车离开操作Stack S;InitStack(S);float time12,time22; record e,e1;Queue q; e1=output(L,e); while(e.number!=number) input(S,e1); e1=output(L,e); time10=_time0; /入车站时间time11=_time1;time20=e.bian_time0; /入便道时间time21=e.bian_time1; jiaofei(time,time1,time2); / while(StackEmpty(S) input(L,output(S,e1); while(QEmpty(Q)&Stackman(L) outqueue(Q,q); /printf(nn请输入汽车从便道进入停车场的时间,输入格式为(时 空格 分):); e.bian_time0=q-int_time0; e.bian_time1=q-int_time1; /scanf(%f %f,&time20,&time21); _time0=time0; _time1=time1; e.number=q-number; printf(n汽车从便道退出进入停车场); printf(n请将%d号车停在%d号位置!n,e.number,L.top-L.base+1); input(L,e); /void xunhuan(Stack L,Linkqueue Q) /选择操作及循环/Queue q; char ch; int number; float time2,time22; fflush(stdin); printf(nA:进入停车场 D:退出停车场 E:退出管理系统n); printf(n请输入:); scanf(%c,&ch);fflush(stdin); switch(ch) case A: printf(n请输入车牌号: ); scanf(%d,&number); printf(请输入入场时间,输入格式为(时 空格 分):); scanf(%f %f,&time0,&time1); if(Stackman(L) record e; _time0=time0; _time1=time1; e.bian_time0=0.0; e.bian_time1=0.0; e.number=number; printf(请将车停在%d号位置!,L.top-L.base+1); input(L,e); else enqueue(Q,number,time); printf(n); printf(n1、继续操作 2、退出操作 : ); jixu(L,Q); break; case D: if(StackEmpty(L) printf(请输入离开汽车的车牌号:); scanf(%d,&number); printf(输入汽车离开时间:); scanf(%f %f,&time20,&time21); leave(L,Q,number,time2); else printf(停车场为空n); printf(n1、继续操作 2、退出操作 : ); jixu(L,Q); break; case E: printf(*退出管理系统*n); break; default: printf(输入错误,请重新输入!n); printf(#n); xunhuan(L,Q); break; /void main() /主函数操作
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025审计招聘笔试题及答案
- 2025商务拓展经理校招真题及答案
- 2025人事专员招聘题库及答案
- 2025【林地承包经营权转让合同】林地承包经营权
- 2025秋招:智能制造技术岗笔试题及答案
- 2025年中考甘肃历史真题及答案
- 2025年贵阳色彩联考真题及答案
- 2025年杭州市存量房屋买卖合同范本
- 996工作制合法性争议中“同意”真实性的社会学质疑
- 武安小学考试试卷及答案
- 紧急输血专家共识课件
- 向人大申请监督申请书
- 2025年初级会计考试真题及参考答案
- 低头族现象分析与应对策略
- 研发部门激励活动方案
- 民法典合同编案例课件
- 甘蔗制糖毕业论文
- 2025至2030中国航空燃油行业发展趋势分析与未来投资战略咨询研究报告
- 初中英语人称代词专项练习题
- 2025年浙江省公安机关人民警察特殊职位公务员招录考试(网络安全技术)历年参考题库含答案详解(5套)
- 房屋安全性鉴定方案
评论
0/150
提交评论