版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、c语言停车场管理问题 c语言版的.停车场问题 (xx-11-25 11:34:23) #include #include #include=1&chtop=0; for(i=0;istacks-top=NULL; int InitQueue(LinkQueueCar *Q) /*初始化便道*/ Q-head=(QueueNode *)malloc(sizeof(QueueNode); if(Q-head!=NULL) Q-head-next=NULL; Q-rear=Q-head; return(1); else return(-1); void PRINT(CarNode *p,int ro
2、om) /*打印出站车的信息*/ int A1,A2,B1,B2; printf(nplease input thedepart time:/*:*/); scanf(%d:%d,&(p-),&(p-); printf(nthe number of the car:); puts(p-num); printf(nthe time the car arrive: %d:%d,p-); printf(the depart time: %d:%d,p-); a1=p- a2=p- b1=p- b2=p- printf(nthe fee: %2.1f元,(B1-A1)*60+(B2-A2)*price
3、); free(p); int Arrival(SeqStackCar *Enter,LinkQueueCar *W) /*车辆到达*/ CarNode *p; QueueNode *t; p=(CarNode *)malloc(sizeof(CarNode); flushall(); printf(ninput the number of the car(例:陕A1234):); gets(p-num); if(Enter-top Enter-top+; printf(nthe place of the car.,Enter-top); printf(nthe time thecar arr
4、ive:/*:*/); scanf(%d:%d,&(p-),&(p-); Enter-stackEnter-top=p; return(1); else /*车场已满,车进便道*/ printf(n该车须在便道等待!); t=(QueueNode *)malloc(sizeof(QueueNode); t-data=p; t-next=NULL; W-rear-next=t; W-rear=t; return(1); void Leave(SeqStackCar *Enter,SeqStackCar *Temp,LinkQueueCar *W) /*车辆离开*/ int i, room; Ca
5、rNode *p,*t; QueueNode *q; /*判断车场内是否有车*/ if(Enter-top0) /*有车*/ while(1) /*输入离开车辆的信息*/ printf(n请输入车在车场的位置/1-%d/:,Enter-top); scanf(%d,&room); if(room=1&roomtop) break; while(Enter-toproom) /*车辆离开*/ Temp-top+; Temp-stackTemp-top=Enter-stackEnter-top; Enter-stackEnter-top=NULL; Enter-top-; p=Enter-stac
6、kEnter-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-; PRINT(p,room); /*判断通道上是否有车及车站是否已满*/ if(W-head!=W-rear)&Enter-top q=W-head-next; t=q-data; Enter-top+; printf(n便道的%s号车进入车场第%d位置.,t-num,Enter-to
7、p); printf(n请输入现在的时间/*:*/:); scanf(%d:%d,&(t-),&(t-); 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 List1(SeqStackCar *S) /*列表显示车场信息*/ int i; if(S-top0) /*判断车站内是否有车*/ printf(n车场:); printf(n 位置 到达时间 车牌号n); f
8、or(i=1;itop;i+) printf( %d ,i); printf(%d:%d ,s-stacki-i-); puts(S-stacki-num); else printf(n车场里没有车); void List2(LinkQueueCar *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 List(SeqStackCar S,LinkQueueCar W) int flag,tag; flag=1; while(flag) printf(n请选择 1|2|3:); printf(n1.车场n2.便道n3.返回n); while(1) scanf(%d,&tag); if(tag=1|tag=3) break; else printf(n请选择 1|2|3:); switch(tag) case 1:List1(&S);break; /*列表显示车场信息*/ case 2:List2(&W);break;
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年口腔医疗管理公司院感防控培训管理制度
- 广西河池市宜州区2024-2025学年八年级上学期期末生物试题(含答案)
- 护理部护理服务特色汇报
- 紧急护理人力资源应急响应机制
- 债权人公告制度
- 信贷员尽职免责制度
- 住院总医师岗位制度
- 企业询价制度
- 成功案例|如何进行工时制度改革与定岗定编?-华恒智信车辆检测维修企业降本增效实践案例解析
- 产品开发委托制度
- 2026湖北随州农商银行科技研发中心第二批人员招聘9人笔试模拟试题及答案解析
- 2025年-辅导员素质能力大赛笔试题库及答案
- 2025年老年娱乐行业艺术教育普及报告
- 2025年抗菌药物合理应用培训考核试题附答案
- 2025年度临床医生个人述职报告
- 2026年烟花爆竹安全生产法律法规知识试题含答案
- 2026年《必背60题》 计算机科学与技术26届考研复试高频面试题包含详细解答
- 2026年无锡商业职业技术学院单招职业技能笔试备考试题带答案解析
- 2026年初二物理寒假作业(1.31-3.1)
- 2025秋人教版七年级上册音乐期末测试卷(三套含答案)
- 2025-2030中国工业硅行业市场现状供需分析及投资评估规划分析研究报告
评论
0/150
提交评论