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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

停车场管理系统.docx

1、停车场管理系统 This manuscript was revised on November 28, 2020停车场管理系统停车场管理系统实验目的综合运用线性表、队列、排序、随机数等数据结构知识,掌握并提高分析、设计、实现及测试程序的综合能力。实验内容及要求停车场拥有M个车位和一条进入停车场的便道,便道上最多停放N辆汽车。汽车要想进入车位,首先进入便道等候。若有空闲车位,则停车入位,否则在便道继续等候,直至有车位空出。若便道已经停满等候的汽车,后到达的汽车只能离开,选择其他停车场。设计一个停车场管理系统,模拟停车场的运作,并统计停车场的收入。(1)使用随机数产生某一时间段内进入和离开停车场的

2、车辆数目;(2)存储并记录如下数据项:汽车到达和离去的时间及汽车的车号;(3)车辆到达时,提示汽车的停车位置编号(为车辆分配编号最小的可用车位),若车位已满给出相应提示;(4)汽车离去时,输出汽车在停车场内停留的时间和应交纳的费用。(5)对该停车场进行统计:统计每天到达、离开的车次,停车总时数、每天停车场的收入等。测试数据M=30,N=5,以1小时为时间的最小单位,每小时停车费30元,每小时到达的车辆数目在0-20辆之间均匀分布,车辆停留1小时后离开的概率是25%,每多停留1小时后离开概率增加25%,4小时后一定要离开。一天以24小时计算。实现提示用队列模拟便道,可用车位需按照编号排序,申请车

3、位时分配编号最小的车位,可用车位动态变化,选择排序方法时应考虑算法效率。#include #include #include #include using namespace std;/*车位*/class chewei private: bool biaozhi; /用来标识车位是否被占用 int intime,outtime; /车位上的车辆的进站时间和出站时间 int zongshijian,zongfeiyong; /该车位上总时间和产生的总费用 int zongchel; /总共离开车辆数 int chepai; /在该车位上停车的车辆的车牌号 int time; /车辆停留时间pu

4、blic: chewei()biaozhi=true;intime=0;zongshijian=0;zongfeiyong=0;zongchel=0; void shezhibz()biaozhi=false; /判断该车位上是否有车 void shezhicp(int cp)chepai=cp; /车到来的时候将车牌号改为该车的车牌号 void incar(int cp,int sj); /车辆进入 void outcar(int sj); /车辆出来 int tingliusj(int t); /查看该车的停留时间 int alltime(); /总时间 int allcost(); /总

5、费用 int allcar();void chewei:incar(int cp,int sj) biaozhi=false; chepai=cp; intime=sj;void chewei:outcar(int sj) int time,feiyong; time=sj-intime; feiyong=time*30; biaozhi=true; cout车牌号为: chepaiendl; cout进入车库时间为: intimeendl; cout离开车库时间为: sjendl; cout停车时间为: timeendl; cout需缴纳停车费为: feiyongendlendl; ofst

6、ream outfile(jilu.txt,ios:app); outfile车牌号为: chepaiendl; outfile进入车库时间为: intimeendl; outfile离开车库时间为: sjendl; outfile停车时间为: timeendl; outfile需缴纳停车费为: feiyongendlnext=NULL; void kongche(int item); /将空车位插入其中 int shanchu(); /车位被占就从中删除它 int changdu()return length; /空闲车位的总量;void kycw:kongche(int item) /按照

7、从小到大的顺序将空车位插入其中 ky * p, * q; p=head-next; length+; if(p=NULL) head-next=new ky(item,NULL); else if(p-haomaitem) head-next=new ky(item,p); else while(p-next!=NULL)&(p-haomanext; if(p-next=NULL)&(p-haomaitem) q=head-next; while(q-next)-next!=NULL) q=q-next; q-next=new ky(item,p); else p-next=new ky(it

8、em,p-next); int kycw:shanchu() /弹出最小的车位 ky * p; length-; p=head-next; int a; a=p-haoma; head-next=p-next; return a;/*便道*/struct node int data; node *next; node(node *nextnode=NULL) next=nextnode; node(int item,node *nextnode=NULL) data=item; next=nextnode; ;class biandaoprivate: node *head; int leng

9、th;public: biandao() head=new node(); length=0; bool isempty() /判断便道是否为空 return head-next=NULL; int changdu() /便道中剩余车辆 return length; void jinrubiandao(int cp); /车辆进入便道 int jinrucheku();void biandao:jinrubiandao(int cp) /车辆进入便道 node *p; p=head; length+; while(p-next!=NULL) p=p-next; p-next=new node(

10、cp,NULL);int biandao:jinrucheku() /便道最前端的车进入停车位,记下车牌号 length-; node *p; int c; p=head; c=p-next-data; head-next=(p-next)-next; return c;/*主程序*/int main() int M=4; int N=2; chewei cw4; biandao bd; kycw keyong; int chep500; int t,number,number1,number2,i,j,k,l,m,c,cphao; cphao=1; coutendlendl; cout 车位

11、数为: 4endl; cout 便道数为: 2endl; cout 每小时停车费用为: 30元endlendl; ofstream outfile(jilu.txt,ios:app); outfile 车位数为: 4endl; outfile 便道数为: 2endl; outfile 每小时停车费用为: 30元endlendl; for(i=0;iM;i+) keyong.kongche(i); for(i=0;i500;i+) chepi=i; for(t=0;t5;t+) i=0;j=0;k=0;l=0; coutendlendl; cout*t小时*endl; outfileendlen

12、dl; outfile*t小时*endl; for(m=0;mM;m+) if(cwm.tingliusj(t)=1) /停车时间为一小时的车,25%离开车库 i=rand()%4; if(i=0) cout停车位为: mendl; ofstream outfile(jilu.txt,ios:app); outfile停车位为: mendl; cwm.outcar(t); keyong.kongche(m); if(cwm.tingliusj(t)=2) /停车时间为二小时的车,50%离开车库 j=rand()%4; if(j2) cout停车位为: mendl; ofstream outfi

13、le(jilu.txt,ios:app); outfile停车位为: mendl; cwm.outcar(t); keyong.kongche(m); if(cwm.tingliusj(t)=3) /停车时间为三小时的车,75%离开车库 k=rand()%4; if(k3) cout停车位为: mendl; ofstream outfile(jilu.txt,ios:app); outfile停车位为: mendl; cwm.outcar(t); keyong.kongche(m); if(cwm.tingliusj(t)=4) /停车时间为四小时的车,100%离开车库 cout停车位为: m

14、endl; ofstream outfile(jilu.txt,ios:app); outfile停车位为: mendl; cwm.outcar(t); keyong.kongche(m); number1=keyong.changdu(); /可用车位的数量 number2=bd.changdu(); /便道中剩余车辆 j=rand()%6; /随机产生该小时来停车场的车辆 cout第t小时来停车场的车辆数量为: jendlendl; ofstream outfile(jilu.txt,ios:app); outfile第t小时来停车场的车辆数量为: jendlendl; if(number

15、2number1) /可用车位比便道中车辆数量多 for(i=0;inumber2;i+) /清空便道 c=bd.jinrucheku(); /取出从便道中进入车库的车牌 number=keyong.shanchu(); /找到可用车位中号码最小的,并从可用车位中删除 cwnumber.incar(c,t); /将该车位状态更新 number1=number1-number2; /剩余的可用车位 if(j=number1) /如果该小时来停车库的车辆少于或等于剩余可用车位 for(i=0;ij;i+) number=keyong.shanchu(); cwnumber.incar(chepcp

16、hao,t); cphao+; else /如果该小时来停车库的车辆比剩余可用车位多 k=j-number1; for(i=0;inumber1;i+) number=keyong.shanchu(); /找到可用车位中号码最小的,并从可用车位中删除 cwnumber.incar(chepcphao,t); /将该车位状态更新 cphao+; for(i=0;ik;i+) if(i=N) cout本车库已满.请去其他停车场停车endl; outfile本车库已满.请去其他停车场停车endl; else /可用车位比便道中车辆数量少或者相等 for(i=0;inumber1;i+) /清理便道

17、c=bd.jinrucheku(); /取出从便道中进入车库的车牌 number=keyong.shanchu(); /找到可用车位中号码最小的,并从可用车位中删除 cwnumber.incar(c,t); /将该车位状态更新 for(i=0;ij;i+) if(i=N) cout本车库已满.请去其他停车场停车endl; outfile本车库已满.请去其他停车场停车endl; int Alltime=0; int Allcost=0; int Allcar=0; for(i=0;iM;i+) Alltime=Alltime+cwi.alltime(); Allcost=Allcost+cwi.allcost(); Allcar=Allcar+cwi.allcar(); cout总共离开车辆数:Allcarendl; cout停车场总停车时间为: Alltimeendl; cout停车场总营业额为: Allcostendl; outfile总共离开车辆数:Allcarendl; outfile停车场总停车时间为: Alltimeendl; outfile停车场总营业额为: Allcostendl; outfile.close();

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1