停车场代码(2) 继上面的(1) 请帮下忙

来源:百度知道 编辑:UC知道 时间:2024/05/22 08:00:51
void Display(SqStack *s1,LQueue *q){
int k;
QNode *p;
printf("停车场状况:\n");
if(s1->top!=0){
printf("车道 车号\n");
for(k=0;k<s1->top;k++)
printf("%d %d\n",k+1,s1->elem[k].num);
}
else
printf("停车场没有车辆\n");
printf("便道状况:\n");
if(q->front->num){
printf("车道 车号\n");
for(k=1,p=q->front->next;p;p=p->next)
printf("%d %d\n",k++,p->num);
}
else
printf("便道没有车辆\n");
}
void main(){
char ch1,ch2;
SqStack *s1,*s2;
LQueue *q;
ElemType x;
int flag;
s1=(SqStack *)malloc(sizeof(SqStack));
s2=(SqStack *)malloc(sizeof(SqStack));
q=(LQueue *)malloc(sizeof(LQueue));
InitStack_Sq(s1);
InitStack_Sq(s2);
InitQueue_L(q);
flag=True;

有一个字符串我加了一个分号,这是一个问题,可能是笔误

主函数我改了一下,可以正常运行,你测试一下

#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
#define N 2
#define M 5
#define True 1
#define False 0

typedef struct{
int num;
int arrtime;
}ElemType;
typedef struct{
ElemType elem[N];
int top;
}SqStack;
typedef struct node{
int num;
struct node *next;
}QNode;
typedef struct{
QNode *front,*rear;
}LQueue;
void InitStack_Sq(SqStack *s){
s->top=0;
}
int Push_Sq(SqStack *s,ElemType x){
if(s->top==M)
return 0;
s->elem[s->top]=x;
s->top++;
return 1;
}
ElemType Pop_Sq(SqStack *s){

ElemType x,y;
if(s->top==0)
return y;
s->top--;
x=s->elem[s->top];
return x;
}
void InitQueue_L(LQueue *q){
QNode