问题遇到的现象和发生背景
链式队列中头指针的next什么时候改变的
问题相关代码,请勿粘贴截图
void InitQueue(LinkQueue &Q){
Q.head=Q.rail=(LNode *)malloc(sizeof(LNode));
Q.head->next=NULL;
}
void InsertQueue(LinkQueue &Q,Elemtype ele){
LNode p=(LNode)malloc(sizeof(LNode));
p->data=ele;
printf("插入成功\n");
p->next=NULL;
Q.rail->next=p; //尾指针指向的结点的指针域指向P 在这句代码之前 变量Q.head->next 一直等于0X0 执行完这段代码后 其跟rail->next的值一致了 求解
Q.rail=p; //尾指针定位到P
}