链队 求教
小白求教
typedef char QElemType;
typedef int Status;
typedef struct Duilie{
QElemType data;
struct Duilie *next;
}Duilie,*Dl;
typedef struct {
Dl front;
Dl rear;
}DL;
Status InitQueue(DL &G){//初始化
G.front=G.rear=new Duilie;
G.front->next=NULL;
return OK;
}
Status EnQueue(DL &G,QElemType e){//入队
Dl Q;
Q->data=e;
Q->next=NULL;
G.rear->next=Q;
G.rear=Q;
return OK;
}
Status DeQueue(DL &G,QElemType &e){//出队
if(G.frontG.rear)
return ERROR;
Dl Q;
Q=G.front->next;
e=Q->data;
G.front->next=Q->next;
if(G.rearQ)
G.rear=G.front;
delete Q;
return OK;
}
QElemType GetHead(DL G){//取队头元素
if(G.rearG.front)
return ERROR;
return G.front->next->data;
}
Status QueueEmpty(DL G){
if(G.rearG.front)
return OK;
else
return ERROR;
}
这里面的问题在哪里,我实在找不到。。