ImageVerifierCode 换一换
格式:DOCX , 页数:11 ,大小:200.87KB ,
资源ID:7395732      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-7395732.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(停车场管理系统.docx)为本站会员(wj)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

停车场管理系统.docx

1、问题描述:设停车场内只有一个可停放n辆汽车的狭长通道,且只有一个大门可以供汽车进出。汽车在停车场内按照车辆到达的先后顺序,依次由北向南排列,大门在最南段。若停车场内车位已经停满,则后来的车位只能停在过道上等候。一旦停车场内有车离开,停靠在过道上的车辆就能开进停车场停放。根据每辆车在停车场的停靠时间计费。请设计一个停车场管理系统。实验代码如下:#include #include #include #include #include #include #include using namespace std;#define MAXNUM 5#define PRICE 2.0struct carch

2、ar num10;struct tm intime;struct tm outime;double expense;int length;int position;/the stack of car/typedef structcar carlistMAXNUM;int top;Seqstack;void Stackinit(Seqstack * s)s-top=-1;int Isempty(Seqstack * s)if(s-top=-1)return 1;elsereturn 0;int Isfull(Seqstack *s)if(s-top=MAXNUM-1)return 1;elser

3、eturn 0;void Stackpush(Seqstack *s,car car1)if(! Isfull(s)s-top+;s-carlists-top=car1;elsecoutits full nowcarlists-top;s-top-;return car1;car Stackgettop(Seqstack *s)car car1;if(! Isempty(s)car1=s-carlists-top;return car1;/the queue of car int tunnel/struct carnodecar data;struct carnode *next;struct

4、 carnodequeuecarnode *head;carnode *rear;void carnodequeueinit(carnodequeue *q)if(!(q-head = (carnode *)malloc(sizeof(carnode)coutfailed to malloc!rear=q-head;q-head-next=NULL;q-rear-next=NULL;int carnodequeueisempty(carnodequeue *q)if(q-rear=q-head)return 1;elsereturn 0;void carnodequeuein(carnodeq

5、ueue *q,car cc)carnode *p;if(!(p=(carnode *)malloc(sizeof(carnode)coutfailed to malloc!data=cc;p-next=NULL;q-rear-next=p;q-rear=p;car carnodequeueout(carnodequeue *q)carnode *p;car cc;if(q-head != q-rear)p=q-head-next;if(p-next=NULL)cc=p-data;q-rear=q-head;free(p);elseq-rear-next=p-next;cc=p-data;fr

6、ee(p);return cc;/ the separator of cout /void separator(int n,char ch,char newline)for(int i=0;in;i+)coutch;if(newline = 1)coutendl;/ print the time struct /void printdata(struct tm gm_data)coutgm_data.tm_mon/gm_data.tm_mday gm_data.tm_hour+8:gm_data.tm_min:gm_data.tm_secendl;/ show park /void showp

7、ark(Seqstack *s)struct tm gm;coutthe park information is follow:endl;separator(40,-,1);if(Isempty(s)coutthe park is empty !endl;elsecoutposition number intime endl;for(int i=0;itop;i+)coutcarlisti.position carlisti.numcarlisti.intime);cout the total is top+1 cars.top = MAXNUM-1)coutand the park is f

8、ull now!endl;elsecoutand the park have top position is empty !head-next;cout the ailse information is follow: endl;separator(30,-,1);coutnumber the intime endl;while(p != NULL)coutdata.numdata.intime);p=p-next;elsecoutthe ailse is empty !endl;separator(30,-,1);coutendl;/ show park and ailse /void sh

9、owall(Seqstack *s,carnodequeue *q)showpark(s);showaisle(q);/ in park /void Inpark(Seqstack *s,carnodequeue *q)car cc;struct tm *gm_data;time_t seconds;time(&seconds); /get the timegm_data=gmtime(&seconds);coutthe number of car cc.num;cc.intime=*gm_data;if(!Isfull(s) & carnodequeueisempty(q)cc.positi

10、on=(s-top)+2;Stackpush(s,cc);showpark(s);else if(Isfull(s) | !carnodequeueisempty(q)coutthe park if full,the car can only park int the ailse .endl;cc.position=MAXNUM;carnodequeuein(q,cc);showall(s,q);/ the out park /void Outpark(Seqstack *s,carnodequeue *q)struct tm *gm_data;time_t seconds;Seqstack

11、p;char nowtime10;int i,pos;car cc;Stackinit(&p);if(Isempty(s)coutthe park is empty,no car need to leave .endl;exit(0);elsecoutthe park information is follow.endl;showpark(s);coutwhich one need to leave ?pos;if(pos 0 & postop+1)for(i=s-top+1;ipos;i-)cc=Stackpop(s);cc.position=cc.position-1;Stackpush(

12、&p,cc);cc=Stackpop(s);time(&seconds);gm_data = gmtime(&seconds);cc.outime=*gm_data;cc.length=mktime(&cc.outime)-mktime(&cc.intime);cc.expense=(cc.length/3600 + 1)*PRICE;coutthe information which car is to leave is follow.endl;coutcc.num cc.length cc.expenseendl;while(! Isempty(&p)cc=Stackpop(&p);Sta

13、ckpush(s,cc);while(!Isempty(s) & !carnodequeueisempty(q)cc=carnodequeueout(q);time(&seconds);gm_data=gmtime(&seconds);cc.intime=*gm_data;Stackpush(s,cc);elsecoutthe car position is wrong!endl;主函数调用为:#include stdafx.h#include example34_car.hint main()Seqstack Park;carnodequeue Aisle;Stackinit(&Park);

14、carnodequeueinit(&Aisle);char choice;do coutendlendl;separator(10,-,0);coutthe management of parkendl;separator(30,-,1);cout1. the car in endl;cout2. the car out endl;cout3. watch the park information endl;cout0. exitendl;separator(56,-,1);coutthe total is MAXNUM position and can park in the ailse if park is full .please choicechoice;switch(choice)case 1:Inpark(&Park,&Aisle);break;case 2:Outpark(&Park,&Aisle);break;case 3:showall(&Park,&Aisle);break; while (choice != 0);return 0;实验结果展示:

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2