carnode.License =a2;
Push(S,carnode);
++CountForStack;
cout<<"车号:"<
Push(tempstack ,temp);//进入暂存栈
}
while(!IsStackEmputy(tempstack))//倒出的车再次进入停车场
{
Pop(tempstack,temp);
Push(S,temp);
}
QNode tempqnode;//用来暂时保存从通道出来的汽车
if(tag1==true&&tag2==false&&tag3==false)//如果出车前停车场已满,并且通道不
为空,并且离开没有失败
{
DeQueue(Q,tempqnode);
--CountForQueue;
temp.ArriveTime =a1 ;
temp.Condition =tempqnode.Condition ;
temp.LeaveTime =tempqnode.LeaveTime ;
temp.License =tempqnode.License ;
Push(S,temp);
}
if(tag2==true&&tag3==false)// 如果停车场没有满,并且离开成功
--CountForStack;
选
择
菜
单
请
按
键
选
择
}
void showmenu(CarStack &S,Queue &Q)
{
cout<<"******************************
*******************************"<>tag;
while(tag!='A'&&tag!='D'&&tag!='E')
cin>>tag;
int a1;
unsigned int a2;
switch(tag)
{
case 'A':
cout<<"请输入到达的车号"<>a1;
cout<<"请输入到达时间"<>a2;
InCar(S,Q,a2,a1);
break;
case 'D':
cout<<"请输入离开的车号"<>a1;
cout<<"请输入离开的时间"<>a2;
OutCar(S,Q,a2,a1);
break;
case 'E':
return ;
break;
}
char ch;
cout<<"******************* 按 E/e 退 出 , 按 任 意 键 返 回 菜 单
**************************"<>ch;
if(ch!='E'&&ch!='e')
showmenu(S,Q);
}
void main()
{
CarStack carstack;
InitStack(carstack);// 建立并且初始化用于停车场的堆栈
Queue carqueue;
InitQueue(carqueue);//建立并且初始化用于通道的队列
showmenu(carstack,carqueue);
}