求代码用C或C++实现停车场有关问题!

求代码用C或C++实现停车场问题!!!
停车场管理:
[问题描述]
          设停车场内只有一个可停放n辆汽车的狭长通道,且只有一个大门可供汽车进出;汽车在停车场内按车辆到达时间的先后顺序,依次由北向南排列(大门在最南端,最先到达的第一辆车停放在车场的最北端),若车场内已停滞n辆汽车,则后来的汽车只能在门外的便道上等候,一旦有车开走,则排在便道上的第一辆车即可开入:当停车场内某辆车要离开时,在它之后开入的车辆必须先退出车场为它让路,待该辆车开出大门外,其他车辆再按原次序进入车场,每辆停放在车场的车在它离开停车场时必须按它停留的时间长短交纳费用.试为停车场编制按上述要求进行管理的模拟程序.
[基本要求]
          以栈模拟停车场,以队列模拟车场外的便道,按照从终端读入的输入数据序列进行模拟管理.每一组输入数据包括三个数据项:汽车 "到达 "或 "离去 "信息、汽车牌照号码及到达或离去的时刻,对每一组输入数据进行操作后的输出数据为:若是车辆到达,则输出汽车在停车场内或便道上的停车位置;若是车辆离去,则输出汽车在停车场内停留的时间及应交纳的费用(在便道上停留的时间不收费)。栈以顺序结构实现,队列以链式结构实现。

PS:真诚希望各位大大确实运行之后再告诉小弟,偶在网上搜了几个程序全都不能执行,谢谢各位了~~~


------解决方案--------------------
用TC编的。主要的要求是:设有一个车站,用栈的结构表示;车站的外面有边道,用队列的结构表示。当车辆进栈的时候,如果栈中有空位,则进栈;如果没有空位,则在边道上等候,直到有栈中的车辆出栈才可以进栈。且出栈的车辆要按在栈中停留的时间交纳费用。

在其中设了一个辅助栈,用来临时容纳为要给离去的车辆让路而退出来的车辆。输入的数据有三个数据项:车辆的进栈或出栈,车牌号,车子 "进出栈 "的时刻;栈中则为车牌号, "进栈 "的时刻;队列中则为车牌号,因为车辆在边道上的等待时间并不计入费用中。


#include <stdio.h>
#include <stdlib.h>
struct {
char status;
int num;
int time;
}a; /*命令的结构*/
typedef struct{
int num;
int time;
}Element;
struct {
Element *base;
Element *top;
int stacksize;
}S,VS; /*S为栈,VS为辅助栈*/
void main(){
typedef struct{
int num;
struct QNode *next;
}QNode,*QueuePtr;
QueuePtr l;
struct {
QueuePtr front;
QueuePtr rear;
}Q; /*队列*/
int n,x,m=0,order,money,b=0;
printf( "\nInput the size of the garage and the cost per hour: ");
scanf( "%d%d ",&n,&x);
S.base=(Element*)malloc(n*sizeof(Element));
S.top=S.base;
S.stacksize=n;
VS.base=(Element *)malloc((n-1)*sizeof(Element));
VS.top=VS.base;
VS.stacksize=n-1;
Q.front=Q.rear=(QueuePtr)malloc(sizeof(QNode));
Q.front-> next=NULL; /*各结构的初始化*/
while (b!=1){
printf( "\nInput the order!: ");
scanf( "%c,%d,%d ",&(a.status),&(a.num),&(a.time));
switch(a.status)
{
case 'E ':b=1;break;
case 'A ':
if (S.top-S.base <S.stacksize){
(*(S.top)).num=a.num;
(*(S.top)).time=a.time;
S.top++;
order=S.top-S.base;
printf( "The %d car is in the %d of garage!\n ",a.num,order);
}
else {
Q.rear=(QueuePtr)malloc(sizeof(QNode));
Q.rear-> next=NULL;
Q.front-> next=Q.rear;
Q.rear-> num=a.num;
m++;
printf( "The %d car is in the %d of Queue!\n ",a.num,m);
}
break;
case 'D ':
while ((*(--S.top)).num!=a.num){
(*(VS.top)).num=(*(S.top)).num;
(*(VS.top)).time=(*(S.top)).time;
VS.top++;
}
money=(a.time-(*(S.top)).time)*x;
printf( "The %d car is out of %d of garage and the cost is %d!\n ",a.num,S.top-S.base+1,money);
while (VS.top!=VS.base){
(*(S.top)).num=(*(--VS.top)).num;
(*(S.top)).time=(*(VS.top)).time;
S.top++;
}
if (m!=0){
l=Q.front-> next;
(*(S.top)).num=l-> num;
(*(S.top)).time=a.time;
S.top++;
printf( "The %d car is in the %d of garage!\n ",l-> num,S.stacksize);