链队的基本操作
来源:互联网 发布:手机微信监控软件 编辑:程序博客网 时间:2024/06/10 16:36
链队的基本操作:
1,存储结构:
2,创建链式队列:
3,队尾插入,队首删除:
4,遍历操作:
typedef int QElemType;typedef struct node{ int data; struct node *next;}QNode,*QueuePre;typedef struct{ QueuePre Front; QueuePre rear;}LinkQueue;void CreatQueue(LinkQueue &Q){ Q.rear=(QueuePre)malloc(sizeof(QNode)); Q.Front=Q.rear; if(!Q.Front) exit(-2); Q.rear->next=NULL;}void EnQueue(LinkQueue &Q,int e){ QueuePre p; p=(QueuePre)malloc(sizeof(QNode)); if(!p) exit(-2); p->data=e; p->next=NULL; Q.rear->next=p; Q.rear=p;}void DeleQueue(LinkQueue &Q,int &e){ QueuePre p; if(Q.Front==Q.rear) return ; p=Q.Front->next; e=p->data; Q.Front->next=p->next; if(Q.rear==p) Q.rear=Q.Front; free(p);}void TraverseQueue(LinkQueue &Q){ if(Q.rear==Q.Front) return; QueuePre p; p=Q.Front->next; while(p) { printf("%d ",p->data); p=p->next; }}
0 0
- 链队的基本操作
- 链队的基本操作
- 链队的基本操作
- 队的基本操作
- 链式队的基本操作
- 链表的基本操作
- 链队列的基本操作
- 链表的基本操作
- 链表的基本操作
- 链表的基本操作
- 链表的基本操作
- 链表的基本操作
- 链表的基本操作
- 链表的基本操作
- 链表的基本操作
- 链表的基本操作
- 链表的基本操作
- 链表的基本操作
- Tomcat(免安装版)的安装与配置
- 运用java操作PDF,生成PDF
- weblogic.jdbc.extensions.PoolLimitSQLException
- 索尼爱立信系统越狱后的问题
- CentOS 6.5 配置IP地址的三种方法
- 链队的基本操作
- C语言Int类型和Double类型小端转大端
- 第十一周项目2调用gcd函数求四位数的最大公约数
- Oracle Applications DBA 基础(一)
- activeMQ发布订阅模式中中常用工具类
- HTML中id、name、class 区别
- 安卓makefile全局变量建立流程分析
- 二叉树的基本操作(二)
- 157 求最大重叠区间大小