csys123 2018-05-08 07:33 采纳率: 100%
浏览 1230
已采纳

停车场收费系统 代码运行不了,求大神修改,按照流程图修改就好

include

include

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

define NULL 0 //空值

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

typedefstructcar_infor
{
intlicen_tag;
inttime;
}SElemType;
typedefstruct
{
SElemType *base1; //通道的栈底指针
SElemType *top1; //通道的栈顶指针
SElemType *base2; //临时道的栈底指针
SElemType *top2; //临时道的栈顶指针
}Stack;
typedefstructQnode
{
intlicen_tag;
inttime;
structQnode *next;
}Qnode,*QueuePtr;
typedefstruct
{
QueuePtr front;
QueuePtr rear;
}LinkQueue;
voidinitStack(Stack &S) //初始化通道与临时道
{
S.base1=(SElemType *)malloc(N*sizeof(SElemType));
S.top1=S.base1;
S.base2=(SElemType *)malloc(N*sizeof(SElemType));
S.top2=S.base2;
}
voidinitQueue(LinkQueue &Q) //初始化便道
{
Q.front=Q.rear=(QueuePtr)malloc(sizeof(Qnode));
Q.front->next=NULL;
}
voidPush1(Stack &S,intlicen_tag,inttime) //车辆进通道
{
S.top1->licen_tag=licen_tag;
S.top1->time=time;
S.top1++;
}
voidPush2(Stack &S) //让路的车辆从通道暂时离开,进临时道
{
S.top2->licen_tag=S.top1->licen_tag;
S.top2->time=S.top1->time;
S.top2++;
S.top1--;
}
voidPop(Stack &S) //车辆从临时道回到通道
{
S.top2--;
S.top1->licen_tag=S.top2->licen_tag;
S.top1->time=S.top2->time;
S.top1++;
}
voidEnQueue(LinkQueue &Q,intlicen_tag,inttime) //通道满时,车辆进便道
{
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;

图片说明

  • 写回答

1条回答 默认 最新

  • dabocaiqq 2018-05-08 08:22
    关注

    修改了一部分,但是一部分代码没有修改,如果你采纳了,帮你修改完。

     # include <iostream>
    # include <stdio>
    # define N 2    //通道允许的最大停车数量,可重新设置
    # define NULL 0  //空值
    # define PRICE 1  //收费单价,可重新设置
    typedef struct car_infor
    {
    intlicen_tag;
    inttime;
    }SElemType;
    typedefstruct
    {
    SElemType *base1;       //通道的栈底指针
    SElemType *top1;        //通道的栈顶指针
    SElemType *base2;       //临时道的栈底指针
    SElemType *top2;        //临时道的栈顶指针
    }Stack;
    typedefstructQnode
    {
    intlicen_tag;
    inttime;
    structQnode *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,intlicen_tag,inttime) //车辆进通道
    {
    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++;
    }
    voidEnQueue(LinkQueue &Q,intlicen_tag,inttime) //通道满时,车辆进便道
    {
    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;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料