停车场管理系统Word文档下载推荐.docx
《停车场管理系统Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《停车场管理系统Word文档下载推荐.docx(12页珍藏版)》请在冰豆网上搜索。
intintime,outtime;
//车位上的车辆的进站时间和出站时间
intzongshijian,zongfeiyong;
//该车位上总时间和产生的总费用
intzongchel;
//总共离开车辆数
intchepai;
//在该车位上停车的车辆的车牌号
inttime;
//车辆停留时间
public:
chewei(){biaozhi=true;
intime=0;
zongshijian=0;
zongfeiyong=0;
zongchel=0;
}
voidshezhibz(){biaozhi=false;
}//判断该车位上是否有车
voidshezhicp(intcp){chepai=cp;
}//车到来的时候将车牌号改为该车的车牌号
voidincar(intcp,intsj);
//车辆进入
voidoutcar(intsj);
//车辆出来
inttingliusj(intt);
//查看该车的停留时间
intalltime();
//总时间
intallcost();
//总费用
intallcar();
};
voidchewei:
:
incar(intcp,intsj){
biaozhi=false;
chepai=cp;
intime=sj;
outcar(intsj){
inttime,feiyong;
time=sj-intime;
feiyong=time*30;
biaozhi=true;
cout<
<
"
车牌号为:
"
chepai<
endl;
进入车库时间为:
intime<
离开车库时间为:
sj<
停车时间为:
time<
需缴纳停车费为:
feiyong<
endl<
ofstreamoutfile("
jilu.txt"
ios:
app);
outfile<
zongshijian=zongshijian+time;
zongfeiyong=zongfeiyong+feiyong;
zongchel=zongchel+1;
intchewei:
allcost(){
returnzongfeiyong;
alltime(){
returnzongshijian;
allcar(){
returnzongchel;
tingliusj(intt){//车辆停留的时间
if(biaozhi==false)
returnt-intime;
else
return0;
/****************************************可用车位*****************************************/
structky{
inthaoma;
ky*next;
ky(ky*nextky=NULL){next=nextky;
ky(intitem,ky*nextky){haoma=item;
next=nextky;
classkycw{
ky*head;
intlength;
kycw(){length=0;
head=newky();
boolisempty(){returnhead->
next==NULL;
voidkongche(intitem);
//将空车位插入其中
intshanchu();
//车位被占就从中删除它
intchangdu(){returnlength;
}//空闲车位的总量
voidkycw:
kongche(intitem){//按照从小到大的顺序将空车位插入其中
ky*p,*q;
p=head->
next;
length++;
if(p==NULL)
head->
next=newky(item,NULL);
else{if(p->
haoma>
item)
next=newky(item,p);
while((p->
next!
=NULL)&
&
(p->
haoma<
item)){
p=p->
}
if((p->
next==NULL)&
q=head->
while((q->
next)->
=NULL)
q=q->
q->
else
p->
next=newky(item,p->
next);
}
intkycw:
shanchu(){//弹出最小的车位
ky*p;
length--;
inta;
a=p->
haoma;
head->
next=p->
returna;
/**********************************便道**********************************/
structnode
intdata;
node*next;
node(node*nextnode=NULL)
{
next=nextnode;
node(intitem,node*nextnode=NULL)
data=item;
classbiandao
node*head;
biandao()
head=newnode();
length=0;
boolisempty()//判断便道是否为空
returnhead->
intchangdu()//便道中剩余车辆
returnlength;
voidjinrubiandao(intcp);
//车辆进入便道
intjinrucheku();
voidbiandao:
jinrubiandao(intcp)//车辆进入便道
node*p;
p=head;
while(p->
p=p->
p->
next=newnode(cp,NULL);
intbiandao:
jinrucheku()//便道最前端的车进入停车位,记下车牌号
intc;
c=p->
next->
data;
next=(p->
returnc;
/******************************主程序*************************/
intmain()
{
intM=4;
intN=2;
cheweicw[4];
biandaobd;
kycwkeyong;
intchep[500];
intt,number,number1,number2,i,j,k,l,m,c,cphao;
cphao=1;
车位数为:
4"
便道数为:
2"
每小时停车费用为:
30元"
for(i=0;
i<
M;
i++)
keyong.kongche(i);
500;
{
chep[i]=i;
for(t=0;
t<
5;
t++)
i=0;
j=0;
k=0;
l=0;
cout<
****************************"
小时**************************"
outfile<
for(m=0;
m<
m++)
{
if(cw[m].tingliusj(t)==1){//停车时间为一小时的车,25%离开车库
i=rand()%4;
if(i==0)
{
cout<
停车位为:
outfile<
cw[m].outcar(t);
keyong.kongche(m);
}
}
if(cw[m].tingliusj(t)==2){//停车时间为二小时的车,50%离开车库
j=rand()%4;
if(j<
2)
if(cw[m].tingliusj(t)==3){//停车时间为三小时的车,75%离开车库
k=rand()%4;
if(k<
3)
{
if(cw[m].tingliusj(t)==4){//停车时间为四小时的车,100%离开车库
cout<
outfile<
cw[m].outcar(t);
keyong.kongche(m);
number1=keyong.changdu();
//可用车位的数量
number2=bd.changdu();
//便道中剩余车辆
j=rand()%6;
//随机产生该小时来停车场的车辆
第"
小时来停车场的车辆数量为:
j<
if(number2<
number1)//可用车位比便道中车辆数量多
{
for(i=0;
number2;
i++)//清空便道
c=bd.jinrucheku();
//取出从便道中进入车库的车牌
number=keyong.shanchu();
//找到可用车位中号码最小的,并从可用车位中删除
cw[number].incar(c,t);
//将该车位状态更新
number1=number1-number2;
//剩余的可用车位
if(j<
=number1)//如果该小时来停车库的车辆少于或等于剩余可用车位
for(i=0;
j;
{
number=keyong.shanchu();
cw[number].incar(chep[cphao],t);
cphao++;
}
else
{//如果该小时来停车库的车辆比剩余可用车位多
k=j-number1;
number1;
cw[number].incar(chep[cphao],t);
}
k;
if(i<
N)
bd.jinrubiandao(chep[cphao++]);
if(i>
=N){
cout<
本车库已满....请去其他停车场停车"
outfile<
}
else//可用车位比便道中车辆数量少或者相等
for(i=0;
i++)//清理便道
c=bd.jinrucheku();
number=keyong.shanchu();
cw[number].incar(c,t);
{
if(i<
bd.jinrubiandao(chep[cphao++]);
if(i>
}
intAlltime=0;
intAllcost=0;
intAllcar=0;
i++){
Alltime=Alltime+cw[i].alltime();
Allcost=Allcost+cw[i].allcost();
Allcar=Allcar+cw[i].allcar();
总共离开车辆数:
Allcar<
停车场总停车时间为:
Alltime<
停车场总营业额为:
Allcost<
outfile.close();