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;

}

694748ed64b9390909c0d88230893790.png

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值