主函数case1里一直无法对p->num赋值 代码如下 题目要求如图片

#include#include#define room 5//停车场可停放的数量typedef struct information//车辆信息{ char num[10];//车牌号 //int where;//0未进停车场 1~5为所在停车场位置 struct information next;}information,*Node;typedef struct //栈 { Node *base; Node *top;}stack;typedef struct//队列{ Node front; Node rear;}queue,*Q;//栈函数----------------------------void Initstack(stack &s)//初始化栈{ s.base=(Node *)malloc(sizeof(Node)*room); s.top=s.base;}int Stackempty(stack &s)//判断栈是否空 空出1 不空出0{ return (s.base ==s.top);}int Stackfull(stack &s)//判断栈满 满出1 不满出0{ return (s.top -s.base>=room);}void Push(stack &s, Node &p) //入栈 { if(Stackfull(s)) printf("停车场已满\n"); else { *s.top=p; s.top++; }}void Pop(stack &s,Node &p){ if(Stackempty(s)!=0) printf("停车场为空\n"); else { p=(--s.top ); }}void Dispstack(stack &s){ Node p; while(p!=*s.top) { p=*s.base++; printf("车牌号为%s的汽车在%d号车位\n",p->num /*,p->where*/ ); }}//队列函数-----------------------------void Initqueue(queue &Q)//队的初始化{ Q.front=Q.rear=(Node)malloc(sizeof(Node)*room); Q.front->next=NULL;}int Queueempty(queue &Q)//判空 空为1 不空为0{ return(Q.front ==Q.rear);}int Queuefull(queue &Q)//判满 满为1 不满为0{ return (Q.rear-Q.front==room);}int EnQueue(queue &Q,Node &p)//入队{ if(Queuefull(Q)!=0) { printf("候车场已满\n"); return 0; } Node q; q=(Node)malloc(sizeof(Node)); q=p; q->next=NULL; Q.rear->next=q; Q.rear=q; return 0;}int DeQueue(queue &Q,Node &p){ if(Queueempty(Q)!=0) { printf("候车场为空\n"); return 0; } p=Q.front; Q.front=Q.front->next; if(Q.rear=p) Q.rear=Q.front; free(p); return 0;}void Dispqueue(queue &Q){ Node p; p=Q.front; while(p!=Q.rear) { printf("车牌号为%s的汽车在%d号车位\n",p->num /*,p->where*/ ); p=p->next; }}//主函数--------------------------------int main(){ int mark=100; Node p; int i,j; stack stop,stopx;//stop为停车场 stopx为汽车离开时的临时停车栈 queue wait;//候车场 Initstack(stop); Initstack(stopx); Initqueue(wait); Node x; x=(*stop.base); printf("请输入指令:\n1.汽车到达\n2.汽车离开\n3.显示停车场情况\n4.显示候车场情况\n0.退出程序\n\n"); scanf("%d",&mark); while(mark!=0) { switch (mark) { case 1://汽车到达 printf("请输入新来汽车的车牌号:"); scanf("%s",p->num); if(!Stackfull(stop))//看停车场是否满 { Push(stop,p);//不满 // printf("%s在停车场%d号位\n",p->num,p->where); } else//满 { if(!Queuefull(wait))//看候车场是否满 EnQueue(wait,p);//buman else printf("停车场、候车场均满不能停车\n"); } break; case 2://汽车离开 printf("请输入离开的汽车的车牌号:"); scanf("%s",&p->num); for(i=0;inum ==p->num ) { i++; break; } }//找到离开的汽车的车位 if(i>=stop.top-stop.base) printf("未找到该汽车\n"); for(j=0;jnum); } break; case 3://显示停车场情况 if(!Stackempty(stop)) { printf("停车场中的车辆:\n"); Dispstack(stop);//输出一遍栈 } else printf("停车场中无车辆\n"); break; case 4://显示候车场情况 if(!Queueempty(wait)) { printf("候车场中的车辆:\n"); Dispqueue(wait);//输出一遍栈 } else printf("候车场中无车辆\n"); break; case 0://结束程序 mark=0; printf("程序结束,感谢使用\n"); break; default: printf("指令输入错误请重新输入"); break; } scanf("%d",&mark); } return 0;}图片

代码如此发帖。。。