2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > php停车场收费系统 停车场收费系统C语言版

php停车场收费系统 停车场收费系统C语言版

时间:2018-12-19 05:23:31

相关推荐

php停车场收费系统 停车场收费系统C语言版

[c]代码库# include

# include

# define N 2 //通道允许的最大停车数量,可重新设置

# define NULL 0 //空值

# define PRICE 1 //收费单价,可重新设置

typedef struct car_infor

{

int licen_tag;

int time;

}SElemType;

typedef struct

{

SElemType *base1; //通道的栈底指针

SElemType *top1; //通道的栈顶指针

SElemType *base2; //临时道的栈底指针

SElemType *top2; //临时道的栈顶指针

}Stack;

typedef struct Qnode

{

int licen_tag;

int time;

struct Qnode *next;

}Qnode,*QueuePtr;

typedef struct

{

QueuePtr front;

QueuePtr rear;

}LinkQueue;

void initStack(Stack &S) //初始化通道与临时道

{

S.base1=(SElemType *)malloc(N*sizeof(SElemType));

S.top1=S.base1;

S.base2=(SElemType *)malloc(N*sizeof(SElemType));

S.top2=S.base2;

}

void initQueue(LinkQueue &Q) //初始化便道

{

Q.front=Q.rear=(QueuePtr)malloc(sizeof(Qnode));

Q.front->next=NULL;

}

void Push1(Stack &S,int licen_tag,int time) //车辆进通道

{

S.top1->licen_tag=licen_tag;

S.top1->time=time;

S.top1++;

}

void Push2(Stack &S) //让路的车辆从通道暂时离开,进临时道

{

S.top2->licen_tag=S.top1->licen_tag;

S.top2->time=S.top1->time;

S.top2++;

S.top1--;

}

void Pop(Stack &S) //车辆从临时道回到通道

{

S.top2--;

S.top1->licen_tag=S.top2->licen_tag;

S.top1->time=S.top2->time;

S.top1++;

}

void EnQueue(LinkQueue &Q,int licen_tag,int time) //通道满时,车辆进便道

{

QueuePtr p;

p=(QueuePtr)malloc(sizeof(Qnode));

p->next=NULL;

Q.rear->next=p;

Q.rear=p;

p->licen_tag=licen_tag;

p->time=time;

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。