struct QueueNode { int Data; struct QueueNode* next; }; struct QueueLink { struct QueueNode* front; struct QueueNode* rear; }; /** * @brief 在队列中插入元素e * @param[in] queue 待插入元素队列 * @param[in] e 插入元素 * @return 返回函数执行结果 * - 0 表示操作成功 * - -1 表示操作失败 * @author wlq_729@163.com * http://blog.csdn.net/rabbit729 * @version 1.0 * @date 2009-03-10 */ int EnQueue(QueueLink* queue, const int e) { if (NULL == queue) { cout<<"point is null!"<<endl; return -1; } QueueNode* p = new QueueNode; if (NULL == p) { cout<<"apply memory is error!"<<endl; return -1; } p->Data = e; p->next = NULL; queue->rear->next = p; queue->rear = p; return 0; }