我是一个初学者,这是我的一个拙作,里面有很多不恰之处,让高手见笑了,请指教。联系我QQ 358271030。
这是用栈和队列模拟的一个停车场管理系统。进来一辆车登记后进入车场,如车场满则进来的车进入便道等候,一旦有车开走则便道自动进入车场。
用一个栈模拟停车场,用一个队列模拟车场外的便道。
#include "stdio.h"
#define NULL 0
#define ERROR 0
#define OK 1
#define OVERFLOW 0
#define STACK_INIT_SIZE 2
typedef struct
{
char label;
float time;
}Car,Car2;
typedef struct
{
Car *top;
Car *base;
int stacksize;
}SqStack;
int InitStack(SqStack *S)
{
S->base=(Car *)malloc(STACK_INIT_SIZE*sizeof(Car));
if(!(S->base)) return ERROR;
S->top=S->base;
S->stacksize=STACK_INIT_SIZE;
return OK;
}
int StackEmpty(SqStack S)
{
if(S.top==S.base)
return OK;
else
return ERROR;
}
int StackFull(SqStack S)
{
if(S.top-S.base>=STACK_INIT_SIZE)
return OK;
else
return ERROR;
}
int Push(SqStack *S,Car e)
{
if(S->top-S->base>=STACK_INIT_SIZE)
return OVERFLOW;
else
{
*(S->top++)=e;
return OK;
}
}
int Pop(SqStack *S,Car *e)
{
if(S->top==S->base)
return ERROR;
*e=*(--(S->top));
}
typedef struct
{
Car2 *top2;
Car2 *base2;
int stacksize2;
}SqStack2;
int InitStack2(SqStack2 *S2)
{
S2->base2=(Car2 *)malloc(STACK_INIT_SIZE*sizeof(Car2));
if(!(S2->top2)) return ERROR;
S2->top2=S2->base2;
S2->stacksize2=STACK_INIT_SIZE;
return OK;
}
int Push2(SqStack2 *S2,Car2 e2)
{
if(S2->top2-S2->base2>=STACK_INIT_SIZE)
return OVERFLOW;
*(S2->top2++)=e2;
return OK;
}
int Pop2(SqStack2 *S2,Car2 *e2)
{
if(S2->top2==S2->base2)
exit(OVERFLOW);
*e2=*(--(S2->top2));
return OK;
}
int StackEmpty2(SqStack2 S2)
{
if(S2.top2==S2.base2)
retu
tplink路由器默认密码是多少(tplink路由器默认密码详解)
tplink路由器默认密码怎么查看(tplink路由器默认密码查看方法)
tplink无线路由器密码怎么重置(tplink无线路由器密码重置方法)
手机如何设置tplink无线路由器密码和密码共享功能(手机设置tplink无线路由器密码和密码共享功能方法)
tplink无线路由器密码忘记了怎么办(tplink无线路由器密码忘记了解决方案)
tplogin路由器可以无线桥接么(TPLink路由器是否支持无线桥接功能)