struct QueueNode { int Data; struct QueueNode* next; }; struct QueueLink { struct QueueNode* front; struct QueueNode* rear; }; /** * @brief 该函数用来建立链式队列 * @return 返回链式队列的指针 * @author wlq_729@163.com * http://blog.csdn.net/rabbit729 * @version 1.0 * @date 2009-03-10 */ QueueLink* CreateQueue() { QueueLink* queue = new QueueLink; assert(queue); queue->front = queue->rear = new QueueNode; queue->rear->next = NULL; int data; bool bInPut = true; while (bInPut) { cin>>data; if (0 == data) { bInPut = false; } else { QueueNode* p = new QueueNode; assert(p); p->Data = data; p->next = NULL; queue->rear->next = p; queue->rear = p; } } return queue; }