PTA - 6-1 带头结点的链队列的基本操作 (10 分)
Status QueueInsert(LinkQueue *Q,ElemType e){
LNode* insertNode = (LNode*)malloc(sizeof(LNode));
if(insertNode == NULL) return ERROR;
insertNode->data = e;
insertNode->next = NULL;
Q->rear->next = insertNode;
Q->rear = insertNode;
return OK;
}
Status QueueDelete(LinkQueue *Q,ElemType *e){
if(Q->front == Q->rear) return ERROR;
LNode* pHead = Q->front->next;
*e = pHead->data;
Q->front->next = pHead->next;
if(pHead == Q->rear){
Q->rear = Q->front;
}
free(pHead);
return OK;
}