标题:停车场管理系统问题
只看楼主
yitingkai
Rank: 1
等 级:新手上路
帖 子:42
专家分:0
注 册:2007-4-26
 问题点数:0 回复次数:0 
停车场管理系统问题
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;
}
}
这是停车场管理系统中用到的几个函数,主函数不会写啊,有哪个高手帮忙看看啊!
搜索更多相关主题的帖子: void top 
2007-05-17 22:14



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-140293-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.094833 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved