相关代码 |
|
void EnQueue_L (LinkQueue &Q, QElemType e) { // 插入元素e为链队列Q中新的队尾元素 p = new LNode; p->data = e; p->next = NULL; Q.rear->next = p; Q.rear = p; }//EnQueue_L bool DeQueue_L (LinkQueue &Q, QElemType &e) { // 若队列不空,则删除Q的队头元素,用e返回其值,并返回TRUE; // 否则返回FALSE if (Q.front == Q.rear) return FALSE; p = Q.front->next; e = p->data; Q.front->next = p->next; if (Q.rear == p) Q.rear = Q.front; delete p; return TRUE; }//DeQueue_L
相关资源 |
|