剑指OFFER之队列
来源:互联网 发布:.net编程语言 编辑:程序博客网 时间:2024/06/04 23:18
#include <stdio.h>#include <malloc.h>#include "common_define.h"#include "jianzhioffer_queue.h"status init_queue(struct linked_queue *Q){ (*Q).front = (*Q).rear = NULL; return OK;}int queue_empty(struct linked_queue Q){ if (!Q.rear && !Q.front) { return 1; } else { return 0; }}status push_queue(struct linked_queue *Q, q_elemtype elem){ struct QNode *p; p = (struct QNode*)malloc(sizeof(struct QNode)); if (!p) { return ERROR; } p->data = elem; p->next = NULL; if (queue_empty(*Q)) { (*Q).front = (*Q).rear = p; } else { (*Q).rear->next = p; (*Q).rear = p; } return OK;} status pop_queue(struct linked_queue *Q, q_elemtype *elem){ struct QNode *p; if (queue_empty(*Q)) { return ERROR; } else { p = (*Q).front; (*elem) = p->data; (*Q).front = p->next; if (!p->next) { (*Q).rear = NULL; } free(p); return OK; }}
0 0
- 剑指OFFER之队列
- 《剑指Offer--栈-队列》
- <剑指offer>之栈和队列所有题目
- <剑指offer>之栈和队列所有题目
- 剑指Offer之用两个栈实现队列
- 剑指Offer之 - 用两个栈实现队列
- 剑指offer之用两个栈实现队列
- 剑指offer之两个栈模拟队列操作
- 剑指offer系列之五:用两个栈实现队列
- 剑指offer面试题之用两个栈实现队列
- 码农小汪-剑指Offer之8 - 两个栈实现队列
- 剑指offer(二)之用两个栈实现队列
- 《剑指offer》之链表、栈和队列专题
- (五)剑指offer之用两个栈实现队列
- 剑指offer之用两个栈实现队列
- 剑指offer 之 两个栈来实现一个队列
- 剑指offer之用两个栈实现队列
- 剑指offer之四---用两个栈实现队列
- 在线算法学习
- ZOJ-2554
- 关于Datasource与数据库连接池的区别。
- 黑马程序员------- 抽象类和接口-------
- XCode 同一Project创建多个target
- 剑指OFFER之队列
- 用Python和Pygame写游戏-从入门到精通(3)
- 【单步调试】 VC
- 梦想从这里开始,退一步海阔天空
- 文本框的长度限制,和类别
- 剑指OFFER之最小堆篇
- IIS服务器应用程序不可用的解决办法
- C#为控件添加拖拽文件事件
- Annotation注解处理器