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