实验5report5Word文件下载.docx
《实验5report5Word文件下载.docx》由会员分享,可在线阅读,更多相关《实验5report5Word文件下载.docx(21页珍藏版)》请在冰豆网上搜索。
陈特:
主函数,函数整合调试,PPT,查看停车场,便道车辆。
洪宇豪:
入栈出栈,栈空栈满函数,费用函数,汽车进停车场函数。
王逸翀:
入队出队函数,汽车进便道函数。
【附录----源程序】
Cpp
#include<
stdio.h>
iostream>
string.h>
string>
stdlib.h>
iomanip>
#defineTRUE1
#defineFALSE0
#definemaxsize3
usingnamespacestd;
typedefstructparking
{
charplate_number[50];
intin_hour;
intin_minute;
intout_hour;
intout_minute;
intnum;
}sp;
//停车场顺序栈
/*typedefstructtemp_parking
stringplatenumber;
}tp;
//临时栈*/
typedefstructwait_load
structwait_load*next;
}wl;
//便道队列
typedefstructlink
wl*front;
wl*rear;
}hlink;
//便道头尾
#include"
SeqStack.h"
LinkQueue.h"
intmain(void)
spparking[maxsize+1],tparking[50],*base,*top,*tbase,*ttop;
intcommand,pnum,wnum,tnum,t1,t2;
hlinkQ;
//wlheadQ;
//top=newsp;
//base=newsp;
//tbase=newsp;
//ttop=newsp;
Q.front=Q.rear=newwl;
Q.front->
next=NULL;
//Q.front->
top=parking;
base=parking;
ttop=tbase=tparking;
//command=2333;
pnum=wnum=tnum=1;
while
(1)
{
system("
cls"
);
cout<
<
"
-----------------------------------------\n"
;
*1.汽车到达*\n"
*2.汽车离开*\n"
*3.查看停车场内停放情况*\n"
*4.查看便道停放情况*\n"
*5.停车场关闭*\n"
//cout<
*6.退出¥*\n"
0-15分钟不收费,不足一小时按一小时计\n"
每小时5元\n"
\n"
cin>
>
command;
while(cin.fail()||command<
1||command>
6)
{
cin.clear();
cout<
请输入一个合法的指令\n"
cin.ignore(1024,'
\n'
cin>
}
switch(command)
case1:
if(full_parking(top,base))
{
EnQueue(Q,wnum);
}
else
in_parking(top,base,pnum);
}
//in_parking(top,base,pnum,wnum,Q);
break;
case2:
if(empty_parking(top,base))
cout<
当前停车场内没有车"
endl;
out_parking(tbase,ttop,top,base,pnum,t1,t2);
inparking(Q,top,wnum,t1,t2);
system("
pause"
case3:
traversepark(top,base);
case4:
traverseQ(Q);
case5:
closepark(top,base,ttop,tbase);
closewl(Q);
cout<
停车场以关闭"
return0;
}
}
SeqStack.h
voidin_parking(sp*&
top,sp*&
base,int&
pnum)
intin_hour,in_minute;
charhour[50];
cout<
******************************"
您当前进行的操作是汽车到达\n"
请输入您的车牌号\n"
//getline(cin,plate_number,'
#'
cin>
plate_number;
请输入到达时间\n"
hour;
sscanf(hour,"
%d:
%d"
&
in_hour,&
in_minute);
//cin>
in_hour>
in_minute>
pnum;
/*if(full_parking(top,base))
停车场已满"
EnQueue(Q,plate_number,in_hour,in_minute,wnum);
}*/
//top->
plate_number=plate_number;
strcpy(top->
plate_number,plate_number);
top->
in_hour=in_hour;
in_minute=in_minute;
num=pnum;
top++;
pnum++;
您当前停车位子为"
"
pnum-1<
system("
intfull_parking(sp*top,sp*base)
if(top-base==maxsize)
returnTRUE;
}
else
returnFALSE;
intempty_parking(sp*top,sp*base){
if(top==base)
returnTRUE;
else
returnFALSE;
doublefee(intin_hour,intin_minute,intout_hour,intout_minute)
doublefee,reduce_minute;
intn=0;
//cout<
in_hour<
in_minute<
out_hour<
out_minute<
reduce_minute=1.00*(out_hour*60+out_minute-(in_hour*60+in_minute));
reduce_minute<
if(reduce_minute>
=0&
&
=15)
fee=0;
elseif(reduce_minute>
15&
60){
fee=5;
fee<
else{
while(reduce_minute>
=0){
n++;
reduce_minute=reduce_minute-60;
}
fee=n*5;
//if(isinteger(reduce_minute/60))
//fee=5*reduce_minute/60;
//else
//fee=5*((int)reduce_minute/60);
returnfee;
voidpop(sp*&
base,sp&
e)
//if(top==base)
停车场已空"
//else
//{
top--;
e.in_hour=top->
in_hour;
e.in_minute=top->
in_minute;
e.out_minute=top->
out_minute;
e.out_hour=top->
out_hour;
//e.plate_number=top->
strcpy(e.plate_number,top->
plate_number);
e.num=top->
num;
//top--;
//}
}
voidpush(/*sp*top,sp*base,*/sp*&
ttop,spe)
//if(top-base==Maxsize)
//else{
//ttop--;
ttop<
inpush"
ttop->
in_hour=e.in_hour;
in_minute=e.in_minute;
out_minute=e.out_minute;
out_hour=e.out_hour;
//ttop->
plate_number=e.plate_number;
strcpy(ttop->
plate_number,e.plate_number);
num=e.num;
ttop++;
//}
voidout_parking(sp*tbase,sp*ttop,sp*&
top,sp*&
pnum,int&
t1,int&
t2)
intout_hour,out_minute;
doublemoney;
intcount;
count=0;
sp*p,*q,*r;
spe;
//p=newsp;
//q=newsp;
//r=newsp;
//if(empty_parking(top,base))
停车场为空"
您当前进行的操作是汽车离开\n"
请输入离开时间\n"
//sscanf(hour,"
out_hour,&
out_minute);
q=top;
here1"
q--;
q<
here2"
for(p=q;
p>
=base;
p--)
p<
if(strcmp(p->
plate_number,plate_number)==0)
find"
count=1;
break;
if(!
count)
当前停车场内没有此车"
return;
//r=p;
p->
out_hour>
pnum--;
p->
out_hour=out_hour;
out_minute=out_minute;
t1=out_hour;
t2=out_minute;
if(p->
out_minute-p->
0)
p->
out_minute=p->
out_minute+60;
out_hour--;
out_hour=p->
out_hour-p->
out_minute=p->
money=fee(p->
in_hour,p->
in_minute,p->
out_hour,p->
停车开始时间"
:
setfill('
0'
)<
setw
(2)<
<
离开时间为"
t1<
t2<
您本次停车时间为"
小时"
分"
<
费用为"
money<
元"
leave_hour<
leave_minute<
'
//top--;
//cout<
地址"
top<
'
top-1<
top-2<
//调试
while(top!
=base&
(strcmp((top-1)->
plate_number,plate_number)!
=0))
便道"
pop(top,base,e);
//cout<
弹出的是"
e.plate_number<
push(/*top,base,*/ttop,e);
压入的是"
//top--;
pop(top,base,e);
here9"
//deleter;
t"
tbase<
while(ttop!
=tbase)
开始压出"
//ttop--;
pop(ttop,tbase,e);
弹出"
e.num--;
push(/*ttop,tbase,*/top,e);
//cout<
here10"
return;
voidtraversepark(sp*top,sp*base)
sp*p;
当前停车场没有车"
序列号"
\t"
车牌号"
停车时间"
for(p=base;
p!
=top;
p++)
num<
plate_number<
voidclosepark(sp*&
base,sp*&
ttop,sp*&
tbase)
top=base;
ttop=tbase;
LinkQueue.h
voidEnQueue(hlink&
Q,int&
wnum)
wl*p;
p=newwl;
//p->
strcpy(p->
num=wnum;
if(Q.front==Q.rear)
Q.front->
next=p;
Q.rear->
Q.rear=p;
当前停车场已满,请您在便道等候,您的序号为"
wnum<
wnum++;
voidinparking(hlink&
Q,sp*&
top,int&
wnum,int&
int