#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
#define True 1
#define False 0
#define ok 1
#define Error 0
#define Infeasible -1
#define Overflow -2
#define price 0.05
//--*-*-*-*-*-*-*-*-车辆信息定义*-*-*-*-*-*-*//
typedef struct{
char AD;//车辆进入的状态A代表进入D代表离开
int car_ID;//车牌号
struct
{
int hour;
int minute;
}time;//车辆进入的时间
}car_info;
car_info car[100];//用以存放每辆车的数据
int i=0;//用于存放车辆进入的坐标
//-------Stack.h-------------------------------//
//Status表示函数的返回状态
typedef int Status;
typedef car_info SElemType;
#define STACK_INIT_SIZE 2//存储空间初始分配量
typedef struct{
SElemType *base;
SElemType *top;
int stacksize;
}SqStack;
Status InitStack(SqStack &S)
{//构造一个空栈s
S.base=(SElemType*)malloc(STACK_INIT_SIZE * sizeof(SElemType));
if(!S.base)
exit(Overflow);
S.top=S.base;
S.stacksize=STACK_INIT_SIZE;
return ok;
}//InitStack
Status StackFull(SqStack S)
{
//栈满则返回TRUE ,否则返回FALSE
if(S.top-S.base>=S.stacksize)
return True;
else
return False;
}//栈满吗
Status StackEmpty(SqStack S)
{
//栈空则返回TRUE ,否则返回FALSE
if(S.top==S.base)
return True;
else
return False;
}//栈空吗
Status Push(SqStack &S,SElemType e)
{//插入元素e为新的栈顶元素
*S.top=e;
S.top++;
return ok;
}//Push
Status Pop(SqStack &S,SElemType &e)
{//若栈不空,则删除S的栈顶元素,用e返回其值
if(S.top==S.base)
return Error;
S.top--;
e=*S.top;
return ok;
}//Pop
//*-**-*-*-*-*queue.h*-*-*-*-*-*-*-//
typedef car_info QElemType;
typedef struct QNode{
QElemType data;
struct QNode *next;
}QNode,*QueuePtr;
typedef struct{
QueuePtr front;
QueuePtr rear;
}LinkQueue;
Status InitQueue(LinkQueue &Q)
{//
停车场管理系统(用栈和队列实现)
最新推荐文章于 2023-03-26 19:51:44 发布