停车场管理系统问题
typedef struct Car{int carnum;
int time;
int mode;
}Car;
typedef struct cpark
{Car *top;
Car *base;
int size;
}cpark;
typedef struct road
{Car *base;
int front;
int rear;
} ;
void InitPark(Cpark *c)
{c->base=(Car*)malloc(PCARSIZE *sizeof(Car));
if(!c->base)exit(0);
c->size=PCARSIZE;
}
void push car(Cpark *c,Car *a)
{if(c->top-c->base>=PCARSIZE)
printf("The park overflow!");
else{c->top->carnum=a->carnum;
c->top->time=a->time;
c->top->mode=a->mode;
c->top+=1;
}
}
void popcar (Cpark *c,Car *a)
{if(c->top==c->base)
printf("The park empty!");
else{--c->top;
a->carnum=c->top->carnum;
a->time=c->top->time;
a->mode=c->top->mode;
}
}
void InitRoad(Road *c)
{c->base=(Car *)malloc(PCARSIZE*sizeof(Car));
if(!c->base)exit(0);
c->front=c->rear=0;
}
void DeRoad(Road *C,Car *a)
{if(c->front=c->rear)
printf("The Road Empty!");
else{a->carnum=(c->base+c->front)->carnum;
a->time=(c->base+c->front)->time;
a->mode(c->base+c->front)->mode;
(c->base+c->front)->carnum=0;
c->front=(c->front+1)%ROADSIZE;
}
}
void EnRoad(Road *c,Car *a)
{if((c->rear+1)%ROADSIZE==c->front)
printf("The Road Overflow!");
else{(c->base+c->rear)->carnum=a->carnum;
(c->base+c->rear)->time=a->time;
(c->base+c->rear)->mode=a->mode;
c->rear=(c->rear+1)%ROADSIZE;
}
}
这是停车场管理系统中用到的几个函数,主函数不会写啊,有哪个高手帮忙看看啊!