main(){
node *h,*t,*q,*g,*gg,*p;
h = NULL;
char in;
do{
int i=5; int numofcar=0;
cin>>in;
switch(in){
case 'A' : if(h==NULL){
h = new node ;
t = h ;
t->next=NULL;
cout<<h->data<<" is waiting"<<endl;
}
else{
q = new node ;
t->next = q;
t=q;
t->next=NULL;
cout<<q->data<<" is waiting"<<endl;
}
break;
case 'P' :
p = h;
cout<<"Car is waiting : ";
if(p){
while(p){
cout<<p->data<<' ';
p = p->next;
}
cout<<endl;
}
else{
cout<<"No car"<<endl;
}
break;
case 'G' :
g = h;
while(g){ numofcar++; g=g->next;}
while(numofcar&&i){
gg = h;
h=h->next;
delete gg;
numofcar--;
i--;
}
break;
case 'Q' : cout<<"EXIT!!!"<<endl; break;
}
}
while(in!='Q');
}