链队列
来源:互联网 发布:专业检测手机信号软件 编辑:程序博客网 时间:2024/05/22 13:16
#include <stdio.h>#include <malloc.h>typedef struct Node{ int data; struct Node* next;}Node;typedef struct Link{ struct Node* rear; struct Node* front;}Link;int init(Link* L){ L->front = (Node*)malloc(sizeof(Node)); if(L->front != NULL) { L->rear = L->front; L->front->next = NULL; return 1; } return 0;}int Enter(Link* L, int x){ Node* NewNode; NewNode = (Node*)malloc(sizeof(Node)); if(NewNode != NULL) { NewNode->data = x; NewNode->next = NULL; L->rear->next = NewNode; L->rear = NewNode; return 1; } else return 0;}int Delete(Link* L, int* x){ Node* r; r = L->front->next; if(r == NULL) //或L->front == L->rear return 0; *x = r->data; L->front->next = r->next; if(L->rear == r) L->rear = L->front; free(r); return 1;}int main(){ Link L; int x; init(&L); Enter(&L, 1); Enter(&L, 2); Enter(&L, 3); Delete(&L, &x); printf("%d\n", x); Delete(&L, &x); printf("%d\n", x); Delete(&L, &x); printf("%d\n", x); return 0;}
0 0
- 队列-循环队列/链队列
- 队列,链队列,循环队列
- 队列,链队列,循环队列
- 队列--链表队列
- 队列之链队列
- 08.队列.链队列
- 队列,链队列,链式存储的队列
- 队列---循环队列与链队列比较
- 顺序队列 - 循环队列 - 链队列
- 链队列
- 链队列
- 链队列
- 链队列
- 链队列
- 链队列
- 链队列
- 链队列
- 链队列
- libevent事件(三)---event_add和epoll_add
- 微信支付 常见报错
- BZOJ 1787 [Ahoi2008]Meet 紧急集合——LCA
- 高性能JavaScript 重绘与重排
- skynet任务调度分析
- 链队列
- 经典蓝牙的基本操作
- 斯坦福「AI百年研究」首份报告:2030年的人工智能与生活
- HDU 5783 Divide the Sequence
- eazyui的css样式加载不了!!急!!大神来帮帮我!!
- 排序算法总结(三)
- 2017年4月20日 工作日记
- 动态规划练习——采药
- 安装python出现is not a supported wheel on this platform解决办法