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; }
posted on 2009-03-10 12:22 张云临 阅读(135) 评论(0) 编辑 收藏 举报