资源描述
#include<iostream>
using namespace std;
void main()
{int i,j,k,m,n,t,x,y,z;
int a[100]={0},b[100]={0},g[100]={0};
char c,e;
long d;
bool f;
i=0;
m=0;
f=true;
cout<<"请输入该停车场的停车位数:";
cin>>n;
cout<<" 成成-停车场 共有 "<<n<<" 个停车位。"<<endl<<endl;
while(f){f=false;
cout<<" =============成成-停车场管理系统============= "<<endl;
cout<<" || || "<<endl;
cout<<" || 1、车辆驶入 2、车辆驶离 3、查询车位 || "<<endl;
cout<<" || 4、查询时间 5、系统说明 6、退出系统 || "<<endl;
cout<<" || || "<<endl;
cout<<" || 收费说明:6元/小时,1角/分钟 || "<<endl;
cout<<" || 成成停车场 --- 竭诚为您服务! || "<<endl;
cout<<" || || "<<endl;
cout<<" ============================================= "<<endl;
cout<<" 请选择操作:";
cin>>k;
if(k==6) cout<<endl<<" =============成哥制作,谢谢使用============== "<<endl<<endl<<" =========系统即将退出,按任意键结束========== "<<endl<<endl;
else if(k==1){if(m<n){m=m+1;cout<<"请输入当前时间:";
cin>>a[i];cout<<a[i]<<":";cin>>b[i];
cout<<"请输入车牌:";
cin>>c>>d;
for(j=0;j<n;j++) if(g[j]==0) {g[j]=j+1;
cout<<" "<<a[i]<<"时"<<b[i]<<"分 "<<"车牌为 "<<c<<d<<" 的车辆 驶入 "<<j+1<<" 号停车位"<<endl<<endl;
t=j+1;a[t]=a[i];b[t]=b[i];j=n;}}
else cout<<" 提示:成成停车场目前已满,无法执行此项操作 "<<endl<<endl;
f=true;}
else if(k==2){if(m==0) cout<<" 提示:成成停车场目前为空,无法执行此项操作 "<<endl<<endl;
else {m=m-1;cout<<"请输入该车所停的车位号:";
cin>>t;if(t<=n){cout<<"请输入当前时间:";cin>>x;cout<<x<<":";cin>>y;
if(y==b[t]){cout<<" "<<x<<"时"<<y<<"分 "<<t<<" 号停车位的车辆驶离 停留时长为 "<<x-a[t]<<"小时"<<y-b[t]<<"分 应收费用 "<<6*(x-a[t])<<" 元"<<endl<<endl;}
else if(y>b[t]){cout<<" "<<x<<"时"<<y<<"分 "<<t<<" 号停车位的车辆驶离 停留时长为 "<<x-a[t]<<"小时"<<y-b[t]<<"分 应收费用 "<<6*(x-a[t])+(y-b[t]-1)/10+1<<" 元"<<endl<<endl;}
else {cout<<" "<<x<<"时"<<y<<"分 "<<t<<" 号停车位的车辆驶离 停留时长为 "<<x-a[t]-1<<"小时"<<60-b[t]+y<<"分 应收费用 "<<6*(x-a[t]-1)+(59-b[t]+y)/10+1<<" 元"<<endl<<endl;}
j=t-1;g[j]=0;}else cout<<" 提示:成成停车场没有该车位,输入错误 "<<endl<<endl;}f=true;}
else if(k==3){for(j=0;j<n;j++) {if(g[j]==0) cout<<j+1<<" 号停车位未停车(空)";
else cout<<j+1<<" 号停车位已停车";cout<<endl;}
cout<<endl;f=true;}
else if(k==4){if(m>0) {cout<<"请输入当前时间:";cin>>x;cout<<x<<":";cin>>y;
cout<<" 于"<<x<<"时"<<y<<"分 "<<"成成停车场共有 "<<m<<" 辆车 停留时长如下:"<<endl;
for(j=0;j<n;j++) if(g[j]!=0) {t=j+1;
if(y>=b[t]) cout<<" "<<t<<" 号车位 已停留 "<<x-a[t]<<"小时"<<y-b[t]<<"分"<<endl;
else cout<<" "<<t<<" 号车位 已停 "<<x-a[t]-1<<"小时"<<60-b[t]+y<<"分"<<endl;}}
else cout<<" 成成停车场目前没有车辆停留,无法查询停留时长 "<<endl;
cout<<endl;f=true;}
else if(k==5){
cout<<" ============================================= "<<endl;
cout<<" || || "<<endl;
cout<<" || 成成停车场 --- 竭诚为您服务! || "<<endl;
cout<<" || || "<<endl;
cout<<" ============================================= "<<endl<<endl;
cout<<" 系统说明如下:"<<endl;
cout<<" 1、时间输入分为两部分,先输入的为小时(0-23),后输入的为分钟(0-59);"<<endl;
cout<<" 2、车牌输入分为两部分,先输入一个字母(大写/小写),后输入一串数字;"<<endl<<endl;
f=true;}
else {cout<<" 提示:没有该项操作,输入错误"<<endl<<" 是否重新选择操作 (Y/N) "<<endl;
cin>>e;if(e=='Y'||e=='y') f=true;}
}
}
展开阅读全文