1.停车场中有车位(分大中小型车,上一级别的车不能停在下一级别的车位上),直接进入停车场停车,洗车店中有车位(不分大中小型车),直接进入洗车店洗车或保养,对于进停车场和洗车店的第一辆车会有提醒操作;
2.停车场车位已满,进入便道等待,洗车店已满,进入便道等待;
3.停车场有车离开,自动检索便车道第一辆车能否进入停车场的该车位,并继续检索便车道的下一辆车能否根据车的信息进入停车场或洗车店,直到便车道的第一辆车不能进入停车场或洗车店或者便车道已经没有车辆停放;
4.洗车店有车离开,自动检索便车道的第一辆车能否进入洗车店,并继续检索便车道下一辆车能否根据车的信息进入停车场或洗车店,直到便车道的第一辆车不能进入停车场或洗车店或者便车道已经没有车辆停放;
5.在停车场和便车道离开的车自动进入收费站(两个),优先选择目前办理业务车辆少的收费站,输入办理业务的时间,并计算两个收费站总的逗留时间,根据总的逗留时间计算出平均逗留时间,判断是否要新增收费站,以便为顾客提供便利;
6.对于停车和洗车的收费标准。停车:根据占地面积和停车时间收费,如果顾客有优惠券,根据优惠券的不同种类对停车收费进行不同程度的优惠。洗车:根据洗车和保养两种不同操作以及顾客是否为会员进行收费,会员会有相对程度的优惠;
7.对停车场和洗车店以及便车道的情况进行查询操作,按序输出车牌号;(可以每个人都执行此操作);
8.对于已经进入停车场、洗车店以及便车道的车辆,如果重复输入车的车牌,进行入场操作,会有报错(提醒顾客检查后重新输入的操作);
9.对于不同的失误操作,我们会提醒顾客检查仔细后,重新输入;
10.对于未进停车场或洗车店,在便车道就离开的车辆,我们会附以真挚的抱歉;
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define INF 0x3f3f3f3f
#define eps (1e-8)
#define N 3 //便车道规模
#define n1 10 //停车场规模
#define n2 5 //洗车店规模
using namespace std;
/* 对于停车场的开放时间,我们认为是从早上7:00到下午8:30。
停车场大中小车位比例为1:3:6,对于停车场的收费标准,前30min免费,超过30min,每小时(不到1个小时按一个小时算)小中大型车分别收取3、4、5元
上一级别的车不能停放在下一级别的车位上
我们认为车主离开停车场或洗车店的时间等于进入收费站的时间,但不同的车办理业务需要的时间不同,所以有的车需要等待前面的办理完业务才能进行业务办理
我们的停车场设有两个收费站,如果办理业务的车主的平均逗留时间(所有车主的逗留时间比上所有车主的数量)超过3min,我们准备增设收费站,为顾客提供便利
*/
struct Car
{
int Operation;//如果是0就代表车主要停车,如果是1就代表车主要洗车,-1代表未进停车场或洗车店就离开
string Num;//车牌
int Begin;//停车||洗车的开始时间
int End;//停车||洗车的结束时间,如果开始时间等于结束时间,就说明未进停车场||洗车店
int Size;//车型,0代表小车,1代表中车,2代表大车
int Time1;//停车时间,End-Begin,由于洗车不按时间计费,所以洗车不需要这个变量
int Member;//如果车主是洗车,要判断车主是否为会员,0为非会员,1为会员
int Kind;//洗车操作还是保养操作
double Expenditure;//花费,不论洗车还是停车,不同车型有不同收费标准
};
int Park_discount[3]= {3,4,5}; //不同车型停车收费
int Wash_discount[3][2]= {{25,20},{30,25},{40,30}}; //不同车型会员与非会员洗车的收费
int Upkeep_discount[3][2]= {{300,270},{350,315},{400,360}}; //不同车型会员与非会员保养车子的收费
vector<Car>carport[3];//车位,carport[0]代表小车位,carport[1]代表中车位,carport[2]代表大车位
vector<Car>car_wash;//洗车店
struct Car Driveway[N];//便车道(双端队列 )
int Driveway_front,Driveway_rear;//双端队列两个指针
int kiss1,kiss2;//标记是否是第一辆进入停车场和洗车店的车
void Leave_carway1(struct node *head);//从便车道进洗车店
void Leave_carway(struct node *head);//从便车道进入停车场
//用双向链表表示双端队列,模拟便车道
struct node
{
struct Car data;
struct node *before,*next;
}*head,*rear;
//链表表示队列,模拟收费站
struct node2
{
int end_Time;
struct node2 *next;
}*head1,*head2,*rear1,*rear2;
int Find_carport(string str)//检查该车是否已在停车场出现过
{
int flag=0;
for(vector<Car>::iterator it=carport[0].begin(); it!=carport[0].end(); it++)
{
if((*it).Num==str)
{
flag=1;
break;
}
}
if(!flag)
{
for(vector<Car>::iterator it=carport[1].begin(); it!=carport[1].end(); it++)
{
if((*it).Num==str)
{
flag=1;
break;
}
}
if(!flag)
{
for(vector<Car>::iterator it=carport[2].begin(); it!=carport[2].end(); it++)
{
if((*it).Num==str)
{
flag=1;
break;
}
}
return flag;
}
else
{
return flag;
}
}
else
{
return flag;
}
return flag;
}
int Find_car_wash(string str)//检查该车是否已在洗车店出现过
{
int flag=0;
for(vector<Car>::iterator it=car_wash.begin(); it!=car_wash.end(); it++)
{
if((*it).Num==str)
{
flag=1;
break;
}
}
return flag;
}
int Find_car_way(struct node *head,string str)//检查该车是否已在便车道出现过
{
struct node *p;
int flag=0;
for(p=head->next; p; p=p->next)
{
if(p->data.Num==str)
{
flag=1;
break;
}
}
return flag;
}
int Car_Information1(struct Car *p1)//进入停车场的车的信息
{
int flag=0;
p1->Operation=0;
cout<<"请输入车牌号:";
cin>>p1->Num;
if(Find_carport(p1->Num))//就说明在停车场里找到了这辆车
{
cout<<"该辆车已经在停车场中,请检查后重新输入~"<<endl;
}
else
{
if(Find_car_wash(p1->Num))//说明在洗车店找到了这辆车
{
cout<<"该辆车已经在洗车店中,请检查后重新输入~"<<endl;
}
else
{
if(Find_car_way(head,p1->Num))
{
cout<<"该辆车已经在便车道中,请检查后重新输入~"<<endl;
}
else
{
flag=1;
if(!kiss1)
{
cout<<"=========您是本停车场第一位顾客哦~========="<<endl;
kiss1=1;
}
cout<<"0:小型车"<<" "<<"1:中型车"<<" "<<"2:大型车"<<endl;
cout<<"请输入车型:";
while(cin>>p1->Size)
{
if(p1->Size==0||p1->Size==1||p1->Size==2)
{
break;
}
else
{
cout<<"您的输入有误,请检查后重新输入"<<endl;
cout<<"0:小型车"<<" "<<"1:中型车"<<" "<<"2:大型车"<<endl;
cout<<"请输入车型:";
}
}
cout<<"停车场开放时间为上午七点到下午八点半"<<endl;
cout<<"请输入进入停车场的时间,输入格式必须严格为00:00:";
string str_time;
while(cin>>str_time)
{
if(str_time.size()==5&&(str_time[0]>='0'&&str_time[0]<='9')&&(str_time[1]>='0'&&str_time[1]<='9')&&(str_time[2]==':')&&(str_time[3]>='0'&&str_time[3]<='9')&&(str_time[4]>='0'&&str_time[4]<='9'))
{
p1->Begin=((str_time[0]-'0')*10+(str_time[1]-'0')-7)*60+(str_time[3]-'0')*10+(str_time[4]-'0');
if(p1->Begin>=0&&p1->Begin<=810)
{
break;
}
else
{
cout<<"您的时间输入有误,请检查后重新输入:";
cout<<"停车场开放时间为上午七点到下午八点半"<<endl;
cout<<"请输入正确进入停车场的时间:";
}
}
else
{
cout<<"您输入的格式有误,请检查后重新输入~"<<endl;
cout<<"停车场开放时间为上午七点到下午八点半"<<endl;
cout<<"请输入进入停车场的时间,输入格式必须严格为00:00:";
}
}
cout<<endl;
}
}
}
return flag;
}
int Car_Information2(struct Car *p1)//进入洗车店的车的信息
{
int flag=0;
p1->Operation=1;
cout<<"请输入车牌号:";
cin>>p1->Num;
if(Find_carport(p1->Num))//就说明在停车场里找到了这辆车
{
cout<<"该辆车已经在停车场中,请检查后重新输入~"<<endl;
}
else
{
if(Find_car_wash(p1->Num))//说明在洗车店找到了这辆车
{
cout<<"该辆车已经在洗车店中,请检查后重新输入~"<<endl;
}
else
{
if(Find_car_way(head,p1->Num))
{
cout<<"该辆车已经在便车道中,请检查后重新输入~"<<endl;
}
else
{
flag=1;
if(!kiss2)
{
cout<<"=========您是本店第一位顾客哦~========="<<endl;
kiss2=1;
}
cout<<"0:小型车"<<" "<<"1:中型车"<<" "<<"2:大型车"<<endl;
cout<<"请输入车型:";
while(cin>>p1->Size)
{
if(p1->Size==0||p1->Size==1||p1->Size==2)
{
break;
}
else
{
cout<<"您的输入有误,请检查后重新输入~"<<endl;
cout<<"0:小型车"<<" "<<"1:中型车"<<" "<<"2:大型车"<<endl;
cout<<"请输入车型:";
}
}
cout<<"0:不是会员"<<" "<<"1.是会员"<<endl;
cout<<"是否为会员:";
while(cin>>p1->Member)
{
if(p1->Member==0||p1->Member==1)
{
break;
}
else
{
cout<<"您的输入有误,请检查后重新输入~"<<endl;
cout<<"0:不是会员"<<" "<<"1.是会员"<<endl;
cout<<"是否为会员:";
}
}
cout<<"1:洗车操作 2:保养操作"<<endl;
cout<<"请输入您的选择:";
int i;
while(cin>>i)
{
if(i==1)
{
p1->Kind=1;
break;
}
else if(i==2)
{
p1->Kind=2;
break;
}
else
{
cout<<"您的输入有误,请检查后重新输入~"<<endl;
cout<<"1:洗车操作 2:保养操作"<<endl;
cout<<"请输入您的选择:";
}
}
cout<<endl;
}
}
}
return flag;
}
int Sum_Time;//两个收费站车辆总的逗留时间
int cnt;//进入两个收费站的车的总数量
int ans1;//目前收费站1的车的数量
int ans2;//目前收费站2的车的数量
//进入1窗口
void in_queue1(int start_time,int use_time)//进入收费站的时间,办理业务需要的时间
{
struct node2 *p;
p = new node2;
if(rear1==head1)//说明收费站没有车
{
p->end_Time=start_time+use_time;
Sum_Time=Sum_Time+use_time;
}
else
{
p->end_Time=rear1->end_Time+use_time;
Sum_Time=Sum_Time+rear1->end_Time-start_time+use_time;
}
p->next=rear1->next;
rear1->next=p;
rear1=p;
cnt++;
ans1++;
}
//进入2窗口
void in_queue2(int start_time,int use_time)//进入收费站的时间,办理业务需要的时间
{
struct node2 *q;
q = new node2;
if(rear2==head2)//说明收费站没有车
{
q->end_Time=start_time+use_time;
Sum_Time=Sum_Time+use_time;
}
else
{
q->end_Time=rear2->end_Time+use_time;
Sum_Time=Sum_Time+rear2->end_Time-start_time+use_time;
}
q->next=rear2->next;
rear2->next=q;
rear2=q;
cnt++;
ans2++;
}
//从1窗口出去
void out_queue1(int start_time)
{
struct node2 *p,*q;
p=head1->next;
while(p!=NULL)//出队
{
if(p->end_Time<=start_time)
{
head1->next=p->next;
q=p;
p=p->next;
free(q);
ans1--;
}
else
{
break;
}
}
return;
}
//从2窗口出去
void out_queue2(int start_time)
{
struct node2 *p,*q;
p=head2->next;
while(p!=NULL)//出队
{
if(p->end_Time<=start_time)
{
head2->next=p->next;
q=p;
p=p->next;
free(q);
ans2--;
}
else
{
break;
}
}
return;
}
void Create(struct Car car)//车辆进入便车道
{
struct node *p;
p = new node;
p->data=car;
p->next=NULL;
p->before=rear;
rear->next=p;
rear=p;
}
void Leave_carway(struct node *head)//从便车道进入停车场
{
struct node *p;
p=head->next;
int flag=1;
if(p==NULL)
{
flag=0;
cout<<"便道中已经没有车辆了哦~"<<endl;
}
else
{
if(p->data.Size==0)//是一个小车
{
if(carport[0].size()!=6)//小型车车位未满
{
cout<<"便车道车牌为"<<p->data.Num<<"的车已经驶入停车场了"<<endl;
cout<<"请输入当前时间,格式必须严格为00:00:";
string str_time;
while(cin>>str_time)
{
if(str_time.size()==5&&(str_time[0]>='0'&&str_time[0]<='9')&&(str_time[1]>='0'&&str_time[1]<='9')&&(str_time[2]==':')&&(str_time[3]>='0'&&str_time[3]<='9')&&(str_time[4]>='0'&&str_time[4]<='9'))
{
p->data.Begin=((str_time[0]-'0')*10+(str_time[1]-'0')-7)*60+(str_time[3]-'0')*10+(str_time[4]-'0');
if(p->data.Begin>=0&&p->data.Begin<=810)
{
break;
}
else
{
cout<<"您的时间输入有误,请检查后重新输入~"<<endl;
cout<<"停车场的开放时间为上午七点到下午八点半"<<endl;
cout<<"请输入当前时间:";
}
}
else
{
cout<<"您的输入格式有误,请检查后重新输入~,正确格式为00:00"<<endl;
cout<<"请输入当前时间:";
}
}
carport[0].push_back(p->data);
head->next=p->next;
if(p->next!=NULL)
{
p->next->before=head;
}
else
{
rear=p->before;
}
free(p);
}
else
{
if(carport[1].size()!=3)
{
cout<<"便车道车牌为"<<p->data.Num<<"的车已经驶入停车场了"<<endl;
cout<<"请输入当前时间,格式必须严格为00:00:";
string str_time;
while(cin>>str_time)
{
if(str_time.size()==5&&(str_time[0]>='0'&&str_time[0]<='9')&&(str_time[1]>='0'&&str_time[1]<='9')&&(str_time[2]==':')&&(str_time[3]>='0'&&str_time[3]<='9')&&(str_time[4]>='0'&&str_time[4]<='9'))
{
p->data.Begin=((str_time[0]-'0')*10+(str_time[1]-'0')-7)*60+(str_time[3]-'0')*10+(str_time[4]-'0');
if(p->data.Begin>=0&&p->data.Begin<=810)
{
break;
}
else
{
cout<<"您的时间输入有误,请检查后重新输入~"<<endl;
cout<<"停车场的开放时间为上午七点到下午八点半"<<endl;
cout<<"请输入当前时间:";
}
}
else
{
cout<<"您的输入格式有误,请检查后重新输入~,正确格式为00:00"<<endl;
cout<<"请输入当前时间:";
}
}
carport[1].push_back(p->data);
head->next=p->next;
if(p->next!=NULL)
{
p->next->before=head;
}
else
{
rear=p->before;
}
free(p);
}
else
{
if(carport[2].size()!=1)
{
cout<<"便车道车牌为"<<p->data.Num<<"的车已经驶入停车场了"<<endl;
cout<<"请输入当前时间,格式必须严格为00:00:";
string str_time;
while(cin>>str_time)
{
if(str_time.size()==5&&(str_time[0]>='0'&&str_time[0]<='9')&&(str_time[1]>='0'&&str_time[1]<='9')&&(str_time[2]==':')&&(str_time[3]>='0'&&str_time[3]<='9')&&(str_time[4]>='0'&&str_time[4]<='9'))
{
p->data.Begin=((str_time[0]-'0')*10+(str_time[1]-'0')-7)*60+(str_time[3]-'0')*10+(str_time[4]-'0');
if(p->data.Begin>=0&&p->data.Begin<=810)
{
break;
}
else
{
cout<<"您的时间输入有误,请检查后重新输入~"<<endl;
cout<<"停车场的开放时间为上午七点到下午八点半"<<endl;
cout<<"请输入当前时间:";
}
}
else
{
cout<<"您的输入格式有误,请检查后重新输入~,正确格式为00:00"<<endl;
cout<<"请输入当前时间:";
}
}
carport[2].push_back(p->data);
head->next=p->next;
if(p->next!=NULL)
{
p->next->before=head;
}
else
{
rear=p->before;
}
free(p);
}
else
{
flag=0;
cout<<"便车道暂时没有车能驶入停车场"<<endl;
}
}
}
}
else if(p->data.Size==1)
{
if(carport[1].size()!=3)
{
cout<<"便车道车牌为"<<p->data.Num<<"的车已经驶入停车场了"<<endl;
cout<<"请输入当前时间,格式必须严格为00:00:";
string str_time;
while(cin>>str_time)
{
if(str_time.size()==5&&(str_time[0]>='0'&&str_time[0]<='9')&&(str_time[1]>='0'&&str_time[1]<='9')&&(str_time[2]==':')&&(str_time[3]>='0'&&str_time[3]<='9')&&(str_time[4]>='0'&&str_time[4]<='9'))
{
p->data.Begin=((str_time[0]-'0')*10+(str_time[1]-'0')-7)*60+(str_time[3]-'0')*10+(str_time[4]-'0');
if(p->data.Begin>=0&&p->data.Begin<=810)
{
break;
}
else
{
cout<<"您的时间输入有误,请检查后重新输入~"<<endl;
cout<<"停车场的开放时间为上午七点到下午八点半"<<endl;
cout<<"请输入当前时间:";
}
}
else
{
cout<<"您的输入格式有误,请检查后重新输入~,正确格式为00:00"<<endl;
cout<<"请输入当前时间:";
}
}
carport[1].push_back(p->data);
head->next=p->next;
if(p->next!=NULL)
{
p->next->before=head;
}
else
{
rear=p->before;
}
free(p);
}
else
{
if(carport[2].size()!=1)
{
cout<<"便车道车牌为"<<p->data.Num<<"的车已经驶入停车场了"<<endl;
cout<<"请输入当前时间,格式必须严格为00:00:";
string str_time;
while(cin>>str_time)
{
if(str_time.size()==5&&(str_time[0]>='0'&&str_time[0]<='9')&&(str_time[1]>='0'&&str_time[1]<='9')&&(str_time[2]==':')&&(str_time[3]>='0'&&str_time[3]<='9')&&(str_time[4]>='0'&&str_time[4]<='9'))
{
p->data.Begin=((str_time[0]-'0')*10+(str_time[1]-'0')-7)*60+(str_time[3]-'0')*10+(str_time[4]-'0');
if(p->data.Begin>=0&&p->data.Begin<=810)
{
break;
}
else
{
cout<<"您的时间输入有误,请检查后重新输入~"<<endl;
cout<<"停车场的开放时间为上午七点到下午八点半"<<endl;
cout<<"请输入当前时间:";
}
}
else
{
cout<<"您的输入格式有误,请检查后重新输入~,正确格式为00:00"<<endl;
cout<<"请输入当前时间:";
}
}
carport[2].push_back(p->data);
head->next=p->next;
if(p->next!=NULL)
{
p->next->before=head;
}
else
{
rear=p->before;
}
free(p);
}
else
{
flag=0;
cout<<"便车道暂时没有车能驶入停车场"<<endl;
}
}
}
else
{
if(carport[2].size()!=1)
{
cout<<"便车道车牌为"<<p->data.Num<<"的车已经驶入停车场了"<<endl;
cout<<"请输入当前时间,格式必须严格为00:00:";
string str_time;
while(cin>>str_time)
{
if(str_time.size()==5&&(str_time[0]>='0'&&str_time[0]<='9')&&(str_time[1]>='0'&&str_time[1]<='9')&&(str_time[2]==':')&&(str_time[3]>='0'&&str_time[3]<='9')&&(str_time[4]>='0'&&str_time[4]<='9'))
{
p->data.Begin=((str_time[0]-'0')*10+(str_time[1]-'0')-7)*60+(str_time[3]-'0')*10+(str_time[4]-'0');
if(p->data.Begin>=0&&p->data.Begin<=810)
{
break;
}
else
{
cout<<"您的时间输入有误,请检查后重新输入~"<<endl;
cout<<"停车场的开放时间为上午七点到下午八点半"<<endl;
cout<<"请输入当前时间:";
}
}
else
{
cout<<"您的输入格式有误,请检查后重新输入~,正确格式为00:00"<<endl;
cout<<"请输入当前时间:";
}
}
carport[2].push_back(p->data);
head->next=p->next;
if(p->next!=NULL)
{
p->next->before=head;
}
else
{
rear=p->before;
}
free(p);
}
else
{
flag=0;
cout<<"便车道暂时没有车能驶入停车场"<<endl;
}
}
}
p=head->next;
if(!flag||p==NULL)
{
return;
}
else
{
if(p->data.Operation==0)//说明下一辆车为停车操作
{
Leave_carway(head);
}
else
{
Leave_carway1(head);
}
}
}
void Leave_carway1(struct node *head)//从便车道离开进入洗车店
{
struct node *p;
p=head->next;
int flag=1;
if(p==NULL)
{
flag=0;
cout<<"便道暂时还未停有车辆哦~,暂时还未能有车能够进入洗车店"<<endl;
}
else
{
if(p->data.Operation==1)
{
head->next=p->next;
if(p->next!=NULL)
{
p->next->before=head;
}
else
{
rear=p->before;
}
cout<<"在便道中等待的第一辆车已经进入洗车店了~"<<endl;
car_wash.push_back(p->data);
free(p);
}
else
{
flag=0;
cout<<"便道中第一辆车的操作为停车操作哦~,暂时还未能有车能够进入洗车店"<<endl;
}
}
p=head->next;
if(p==NULL||!flag)
{
return;
}
else
{
if(p->data.Operation==0)//说明下一辆车为停车操作
{
Leave_carway(head);
}
else
{
Leave_carway1(head);
}
}
}
void Leave_carway0(struct node *head,int Size)//从便车道离开进入停车场
{
struct node *p;
int flag=1;
p=head->next;
if(p==NULL)
{
flag=0;
cout<<"便道暂时还未停有车辆哦~,暂时还未能有车能够进入停车场"<<endl;
}
else
{
if(p->data.Operation==0)
{
if(p->data.Size<=Size)
{
head->next=p->next;
if(p->next!=NULL)
{
p->next->before=head;
}
else
{
rear=p->before;
}
cout<<"在便道中等待的第一辆车已经进入停车场了~"<<endl<<endl;
cout<<"请输入当前时间,格式必须严格为00:00:";
string str_time;
while(cin>>str_time)
{
if(str_time.size()==5&&(str_time[0]>='0'&&str_time[0]<='9')&&(str_time[1]>='0'&&str_time[1]<='9')&&(str_time[2]==':')&&(str_time[3]>='0'&&str_time[3]<='9')&&(str_time[4]>='0'&&str_time[4]<='9'))
{
p->data.Begin=((str_time[0]-'0')*10+(str_time[1]-'0')-7)*60+(str_time[3]-'0')*10+(str_time[4]-'0');
if(p->data.Begin>=0&&p->data.Begin<=810)
{
break;
}
else
{
cout<<"您的时间输入有误,请检查后重新输入~"<<endl;
cout<<"停车场的开放时间为上午七点到下午八点半"<<endl;
cout<<"请输入当前时间:";
}
}
else
{
cout<<"您的输入格式有误,请检查后重新输入~,正确格式为00:00"<<endl;
cout<<"请输入当前时间:";
}
}
carport[Size].push_back(p->data);
free(p);
}
else
{
flag=0;
cout<<"便道第一辆车暂时不能驶入停车场"<<endl;
}
}
else
{
flag=0;
cout<<"便道中第一辆车的操作为洗车操作哦~,暂时还未能有车能够进入停车场"<<endl;
}
}
p=head->next;
if(p==NULL||!flag)
{
return;
}
else
{
if(p->data.Operation==0)//说明下一辆车为停车操作
{
Leave_carway(head);
}
else
{
Leave_carway1(head);
}
}
}
int Num(struct node *head)//查看便车道目前暂停的车的数量
{
struct node *p;
int cnt=0;
for(p=head->next; p; p=p->next)
{
cnt++;
}
return cnt;
}
void Erase(struct node *head,string str)//车辆从便车道离开,并在便车道删除这辆车的信息
{
struct node *p;
p=head->next;
int flag=0;
while(p)
{
if(p->data.Num==str)
{
flag=1;
break;
}
else
{
p=p->next;
}
}
if(!flag)
{
cout<<"您的输入有误,请检查后重新输入~"<<endl;
}
else
{
cout<<"您的车辆已在便车道离开,为您带来不便,深感抱歉"<<endl;
struct node *r;
r=p->before;
if(rear==p)
{
rear=r;
}
r->next=p->next;
if(p->next!=NULL)
p->next->before=r;
free(p);
}
return;
}
void Judge_car_way(struct node *head)//查看便道情况
{
cout<<"便道中停车情况:"<<endl;
struct node *p;
p=head->next;
if(p==NULL)
{
cout<<"便道暂时没有车辆哦~"<<endl;
}
else
{
cout<<"便道停有"<<Num(head)<<"辆车"<<endl;
for(p=head->next; p; p=p->next)
{
cout<<"车牌号为:"<<p->data.Num<<endl;
}
}
}
void Judge_carport(vector<Car>carport[])//查看停车场
{
cout<<"停车场中小型车车位停车情况:"<<endl;
cout<<"停车场现在停了"<<carport[0].size()<<"辆车"<<endl;
for(vector<Car>::iterator it=carport[0].begin(); it!=carport[0].end(); it++)
{
cout<<"车牌号为:"<<(*it).Num<<endl;
}
cout<<"停车场中中型车车位停车情况:"<<endl;
cout<<"停车场现在停了"<<carport[1].size()<<"辆车"<<endl;
for(vector<Car>::iterator it=carport[1].begin(); it!=carport[1].end(); it++)
{
cout<<"车牌号为:"<<(*it).Num<<endl;
}
cout<<"停车场中大型车车位停车情况:"<<endl;
cout<<"停车场现在停了"<<carport[2].size()<<"辆车"<<endl;
for(vector<Car>::iterator it=carport[2].begin(); it!=carport[2].end(); it++)
{
cout<<"车牌号为:"<<(*it).Num<<endl;
}
}
void Judge_car_wash(vector<Car>car_wash)//查看洗车店
{
cout<<"洗车店中洗车情况:"<<endl;
int num1=0,num2=0;
for(vector<Car>::iterator it=car_wash.begin(); it!=car_wash.end(); it++)
{
if((*it).Kind==1)
{
num1++;
}
else
{
num2++;
}
}
cout<<"洗车店中有"<<num1<<"辆车执行洗车操作"<<endl;
for(vector<Car>::iterator it=car_wash.begin(); it!=car_wash.end(); it++)
{
if((*it).Kind==1)
{
cout<<"车牌号为:"<<(*it).Num<<endl;
}
}
cout<<"洗车店中有"<<num2<<"辆车执行保养操作"<<endl;
for(vector<Car>::iterator it=car_wash.begin(); it!=car_wash.end(); it++)
{
if((*it).Kind==2)
{
cout<<"车牌号为:"<<(*it).Num<<endl;
}
}
}
int main()
{
head = new node;
head->next = NULL;
rear=head;
head1 = new node2;
head2 = new node2;
head1->next = NULL;
head2->next = NULL;
rear1=head1;
rear2=head2;
cnt=0;
Sum_Time=0;
ans1=0;
ans2=0;
cout<<"=============================欢迎使用slyarh的停车场============================="<<endl<<endl;
cout<<" 本停车场最多可停放10辆汽车"<<endl<<endl;
int i=0;
while(i!=6)
{
cout<<" 1:停车"<<" "<<"2:洗车"<<" "<<"3:离开停车场,结算"<<" "<<"4:离开洗车店,结算"<<" "<<"5.查看系统情况"<<" "<<"6.退出系统"<<endl<<endl;
cout<<"请选择:";
cin>>i;
switch(i)
{
case 1://进行停车操作
{
struct Car car,*p1;
p1=&car;
if(Car_Information1(p1)==1)//返回值为0说明该车已在停车系统中,不能再执行停车操作
{
if(carport[0].size()==6&&carport[1].size()==3&&carport[2].size()==1)
{
if(Num(head)==3)
{
cout<<" 目前停车场已满,还请另寻他处停车~"<<endl<<endl;
}
else
{
cout<<" 目前停车场已满,还请在通道内等待~"<<endl<<endl;
Create(car);
}
}
else
{
if(car.Size==2)//代表大型车
{
if(carport[2].size()==1)//说明大车位已经满了,不能再停车
{
if(Num(head)==3)//便车道已满
{
cout<<" 目前停车场大型车位已满,还请另寻他处停车~"<<endl<<endl;
}
else
{
cout<<" 目前停车场大型车位已满,还请在通道内等待~"<<endl<<endl;
Create(car);
}
}
else
{
cout<<" 目前停车场大型车位未满,进入大型车车位停车"<<endl<<endl;
carport[2].push_back(car);
}
}
else if(car.Size==1)//代表中型车
{
if(carport[1].size()==3)//说明中型车位已满
{
if(carport[2].size()!=1)//说明大型车位未满
{
cout<<" 目前停车场大型车位未满,进入大型车车位停车"<<endl<<endl;
car.Size=2;//由于最后计费是按照车位大小来计算,所以如果中型车在大车型车位停车,要按照大型车车位计费
carport[2].push_back(car);
}
else
{
if(Num(head)==3)
{
cout<<" 目前停车场车位已满,还请另寻他处停车~"<<endl<<endl;
}
else
{
cout<<" 目前停车场车位已满,还请在通道内等待~"<<endl<<endl;
Create(car);
}
}
}
else
{
cout<<" 目前停车场中型车位未满,进入中型车车位停车"<<endl<<endl;
carport[1].push_back(car);
}
}
else if(car.Size==0)//小型车
{
if(carport[0].size()==6)//小型车车位已满
{
if(carport[1].size()!=3)//中型车位未满
{
cout<<" 目前停车场中型车位未满,进入中型车车位停车"<<endl<<endl;
car.Size=1;
carport[1].push_back(car);
}
else
{
if(carport[2].size()!=1)
{
cout<<" 目前停车场大型车位未满,进入大型车车位停车"<<endl<<endl;
car.Size=2;
carport[2].push_back(car);
}
else
{
if(Num(head)==3)
{
cout<<" 目前停车场车位已满,还请另寻他处停车~"<<endl<<endl;
}
else
{
cout<<" 目前停车场车位已满,还请在通道内等待~"<<endl<<endl;
Create(car);
}
}
}
}
else
{
cout<<" 目前停车场小型车位未满,进入小型车车位停车"<<endl<<endl;
carport[0].push_back(car);
}
}
}
}
}
break;
case 2:
{
struct Car car2,*p2;
p2=&car2;
if(Car_Information2(p2))//返回值为0说明该车已在停车系统中,不能再执行停车操作
{
if(car_wash.size()==5)//说明洗车店已满
{
if(Num(head)==3)//说明便车道已满
{
cout<<" 目前洗车店已满,还请另寻他处洗车~"<<endl<<endl;
}
else
{
cout<<" 目前洗车店已满,还请在通道内等待~"<<endl<<endl;
Create(car2);
}
}
else
{
cout<<" 目前洗车店未满,进入洗车店洗车"<<endl<<endl;
car_wash.push_back(car2);
}
}
}
break;
case 3://从停车场取车,并进入收费站
{
cout<<"请输入车牌号:";
string str;
cin>>str;
struct Car car;
int flag=0;
for(vector<Car>::iterator it=carport[0].begin(); it!=carport[0].end(); it++) //如果该车在小型车车位上,保存该车信息,并在小型车车位删除该车
{
if((*it).Num==str)
{
car=*it;
flag=1;
carport[0].erase(it);
break;
}
}
if(flag)//说明已经找到,不需要再继续寻找,并从小型车停车位离开
{
cout<<"请输入您的离开时间,时间格式严格为00:00,并进入收费站:";
string str_time;
int endtime;
while(cin>>str_time)
{
if(str_time.size()==5&&(str_time[0]>='0'&&str_time[0]<='9')&&(str_time[1]>='0'&&str_time[1]<='9')&&(str_time[2]==':')&&(str_time[3]>='0'&&str_time[3]<='9')&&(str_time[4]>='0'&&str_time[4]<='9'))
{
endtime=((str_time[0]-'0')*10+(str_time[1]-'0')-7)*60+(str_time[3]-'0')*10+(str_time[4]-'0');
if(endtime>=car.Begin&&endtime<=810)
{
break;
}
else
{
cout<<"您的时间输入有误,停车场的关闭时间为下午八点半,请检查后重新输入~:";
}
}
else
{
cout<<"您的时间格式输入有误,请检查后重新输入~,正确格式为00:00"<<endl;
cout<<"请输入您的离开时间,并进入收费站:";
}
}
car.End=endtime;
out_queue1(endtime);
out_queue2(endtime);
car.Time1=car.End-car.Begin;
car.Time1-=30;
if(car.Time1<=0)//说明不到三十分钟
{
cout<<"请输入您办理业务所需时间:";
int use_time;
cin>>use_time;
if(ans1<=ans2)//进1号窗口
{
in_queue1(endtime,use_time);
}
else
{
in_queue2(endtime,use_time);
}
cout<<"您本次停车花费:0元"<<endl<<endl;
}
else
{
car.Expenditure=ceil((car.Time1*1.0)/60.0)*Park_discount[0];
cout<<"0:代金券"<<" "<<"1:免单券"<<" "<<"2:打折券"<<" "<<"3:没有券"<<endl<<endl;
cout<<"请选择优惠券类型:";
int j;
while(cin>>j)
{
int flag1=0;
switch(j)
{
case 0:
{
flag1=1;
if(car.Expenditure-5<0)
{
car.Expenditure=0;
}
else
{
car.Expenditure-=5;
}
}
break;
case 1:
{
flag1=1;
car.Expenditure=0;
}
break;
case 2:
{
flag1=1;
car.Expenditure=car.Expenditure*0.7;
}
break;
case 3:
flag1=1;
break;
default:
cout<<"您的输入有误,请检查后重新输入~"<<endl;
cout<<"0:代金券"<<" "<<"1:免单券"<<" "<<"2:打折券"<<" "<<"3:没有券"<<endl<<endl;
cout<<"请选择优惠券类型:";
}
if(flag1)
{
break;
}
}
cout<<"请输入您办理业务所需时间:";
int use_time;
cin>>use_time;
if(ans1<=ans2)//进1号窗口
{
in_queue1(endtime,use_time);
}
else
{
in_queue2(endtime,use_time);
}
cout<<"您本次停车花费:";
cout<<car.Expenditure<<"元,期待您的下次光临"<<endl<<endl;
}
Leave_carway0(head,0);
}
else
{
for(vector<Car>::iterator it=carport[1].begin(); it!=carport[1].end(); it++) //如果该车在中型车车位上,保存该车信息,并在中型车车位删除该车
{
if((*it).Num==str)
{
car=*it;
flag=1;
carport[1].erase(it);
break;
}
}
if(flag)//说明已经找到,不需要再继续寻找
{
cout<<"请输入您的离开时间,时间格式严格为00:00,并进入收费站:";
string str_time;
int endtime;
while(cin>>str_time)
{
if(str_time.size()==5&&(str_time[0]>='0'&&str_time[0]<='9')&&(str_time[1]>='0'&&str_time[1]<='9')&&(str_time[2]==':')&&(str_time[3]>='0'&&str_time[3]<='9')&&(str_time[4]>='0'&&str_time[4]<='9'))
{
endtime=((str_time[0]-'0')*10+(str_time[1]-'0')-7)*60+(str_time[3]-'0')*10+(str_time[4]-'0');
if(endtime>=car.Begin&&endtime<=810)
{
break;
}
else
{
cout<<"您的时间输入有误,停车场的关闭时间为下午八点半,请检查后重新输入~:";
}
}
else
{
cout<<"您的时间格式输入有误,请检查后重新输入~,正确格式为00:00"<<endl;
cout<<"请输入您的离开时间,并进入收费站:";
}
}
car.End=endtime;
out_queue1(endtime);
out_queue2(endtime);
car.Time1=car.End-car.Begin;
car.Time1-=30;
car.Time1=car.End-car.Begin;
car.Time1-=30;
if(car.Time1<=0)//说明不到三十分钟
{
cout<<"请输入您办理业务所需时间:";
int use_time;
cin>>use_time;
if(ans1<=ans2)//进1号窗口
{
in_queue1(endtime,use_time);
}
else
{
in_queue2(endtime,use_time);
}
cout<<"您本次停车花费:0元"<<endl<<endl;
}
else
{
car.Expenditure=ceil((car.Time1*1.0)/60.0)*Park_discount[1];
cout<<"0:代金券"<<" "<<"1:免单券"<<" "<<"2:打折券"<<" "<<"3:没有券"<<endl<<endl;
cout<<"请选择优惠券类型:";
int j;
while(cin>>j)
{
int flag1=0;
switch(j)
{
case 0:
{
flag1=1;
if(car.Expenditure-5<0)
{
car.Expenditure=0;
}
else
{
car.Expenditure-=5;
}
}
break;
case 1:
{
flag1=1;
car.Expenditure=0;
}
break;
case 2:
{
flag1=1;
car.Expenditure=car.Expenditure*0.7;
}
break;
case 3:
flag1=1;
break;
default:
cout<<"您的输入有误,请检查后重新输入~"<<endl;
cout<<"0:代金券"<<" "<<"1:免单券"<<" "<<"2:打折券"<<" "<<"3:没有券"<<endl<<endl;
cout<<"请选择优惠券类型:";
}
if(flag1)
{
break;
}
}
cout<<"请输入您办理业务所需时间:";
int use_time;
cin>>use_time;
if(ans1<=ans2)//进1号窗口
{
in_queue1(endtime,use_time);
}
else
{
in_queue2(endtime,use_time);
}
cout<<"您本次停车花费:";
cout<<car.Expenditure<<"元,期待您的下次光临"<<endl<<endl;
}
Leave_carway0(head,1);
}
else
{
for(vector<Car>::iterator it=carport[2].begin(); it!=carport[2].end(); it++) //如果该车在大型车车位上,保存该车信息,并在大型车车位删除该车
{
if((*it).Num==str)
{
car=*it;
flag=1;
carport[2].erase(it);
break;
}
}
if(flag)//说明已经找到,不需要再继续寻找
{
cout<<"请输入您的离开时间,时间格式严格为00:00,并进入收费站:";
string str_time;
int endtime;
while(cin>>str_time)
{
if(str_time.size()==5&&(str_time[0]>='0'&&str_time[0]<='9')&&(str_time[1]>='0'&&str_time[1]<='9')&&(str_time[2]==':')&&(str_time[3]>='0'&&str_time[3]<='9')&&(str_time[4]>='0'&&str_time[4]<='9'))
{
endtime=((str_time[0]-'0')*10+(str_time[1]-'0')-7)*60+(str_time[3]-'0')*10+(str_time[4]-'0');
if(endtime>=car.Begin&&endtime<=810)
{
break;
}
else
{
cout<<"您的时间输入有误,停车场的关闭时间为下午八点半,请检查后重新输入~:";
}
}
else
{
cout<<"您的时间格式输入有误,请检查后重新输入~,正确格式为00:00"<<endl;
cout<<"请输入您的离开时间,并进入收费站:";
}
}
car.End=endtime;
out_queue1(endtime);
out_queue2(endtime);
car.Time1=car.End-car.Begin;
car.Time1-=30;
car.Time1=car.End-car.Begin;
car.Time1-=30;
if(car.Time1<=0)//说明不到三十分钟
{
cout<<"请输入您办理业务所需时间:";
int use_time;
cin>>use_time;
if(ans1<=ans2)//进1号窗口
{
in_queue1(endtime,use_time);
}
else
{
in_queue2(endtime,use_time);
}
cout<<"您本次停车花费:0元"<<endl<<endl;
}
else
{
car.Expenditure=ceil((car.Time1*1.0)/60.0)*Park_discount[2];
cout<<"0:代金券"<<" "<<"1:免单券"<<" "<<"2:打折券"<<" "<<"3:没有券"<<endl<<endl;
cout<<"请选择优惠券类型:";
int j;
while(cin>>j)
{
int flag1=0;
switch(j)
{
case 0:
{
flag1=1;
if(car.Expenditure-5<0)
{
car.Expenditure=0;
}
else
{
car.Expenditure-=5;
}
}
break;
case 1:
{
flag1=1;
car.Expenditure=0;
}
break;
case 2:
{
flag1=1;
car.Expenditure=car.Expenditure*0.7;
}
break;
case 3:
flag1=1;
break;
default:
cout<<"您的输入有误,请检查后重新输入~"<<endl;
cout<<"0:代金券"<<" "<<"1:免单券"<<" "<<"2:打折券"<<" "<<"3:没有券"<<endl<<endl;
cout<<"请选择优惠券类型:";
}
if(flag1)
{
break;
}
}
cout<<"请输入您办理业务所需时间:";
int use_time;
cin>>use_time;
if(ans1<=ans2)//进1号窗口
{
in_queue1(endtime,use_time);
}
else
{
in_queue2(endtime,use_time);
}
cout<<"您本次停车花费:";
cout<<car.Expenditure<<"元,期待您的下次光临"<<endl<<endl;
}
Leave_carway0(head,2);
}
else//停车场中未找到,去便车道寻找
{
Erase(head,str);
}
}
}
}
break;
case 4://4:离开洗车店,结算
{
cout<<"请输入车牌号:";
string str;
cin>>str;
int flag=0;
struct Car car;
for(vector<Car>::iterator it=car_wash.begin(); it!=car_wash.end();)
{
if((*it).Num==str)
{
flag=1;
car=*it;
car_wash.erase(it);
break;
}
else
{
it++;
}
}
if(flag)//在洗车店找到它了
{
if(car.Kind==1)//洗车操作
{
car.Expenditure=Wash_discount[car.Size][car.Member];
}
else
{
car.Expenditure=Upkeep_discount[car.Size][car.Member];
}
cout<<"请输入您的离开时间,时间格式严格为00:00,并进入收费站:";
string str_time;
int endtime;
while(cin>>str_time)
{
if(str_time.size()==5&&(str_time[0]>='0'&&str_time[0]<='9')&&(str_time[1]>='0'&&str_time[1]<='9')&&(str_time[2]==':')&&(str_time[3]>='0'&&str_time[3]<='9')&&(str_time[4]>='0'&&str_time[4]<='9'))
{
endtime=((str_time[0]-'0')*10+(str_time[1]-'0')-7)*60+(str_time[3]-'0')*10+(str_time[4]-'0');
if(endtime>=car.Begin&&endtime<=810)
{
break;
}
else
{
cout<<"您的时间输入有误,洗车店的关闭时间为下午八点半,请检查后重新输入~:";
}
}
else
{
cout<<"您的时间格式输入有误,请检查后重新输入~,正确格式为00:00"<<endl;
cout<<"请输入您的离开时间,并进入收费站:";
}
}
car.End=endtime;
out_queue1(endtime);
out_queue2(endtime);
cout<<"请输入您办理业务所需时间:";
int use_time;
cin>>use_time;
if(ans1<=ans2)//进1号窗口
{
in_queue1(endtime,use_time);
}
else
{
in_queue2(endtime,use_time);
}
cout<<"您本次洗车花费:";
cout<<car.Expenditure<<"元,期待您的下次光临"<<endl<<endl;
Leave_carway1(head);
}
else
{
Erase(head,str);
}
}
break;
case 5://查看停车场情况
{
Judge_car_way(head);
Judge_carport(carport);
Judge_car_wash(car_wash);
}
case 6://退出系统
break;
default:
{
cout<<"您的输入有误,请检查后重新输入~"<<endl;
}
break;
}
}
//计算平均逗留时间,判断是否要增设收费站
double time=(Sum_Time*1.0)/(cnt*1.0);
if(time>3)
{
cout<<" 需要增设收费站,以便为顾客提供便利"<<endl;
}
else
{
cout<<" 两个收费站足以,不用再增设收费站"<<endl;
}
cout<<endl<<" 已退出slyarh系统,slyarh停车场竭诚为您服务,欢迎下次再来~"<<endl;
return 0;
}