数据结构之队列
来源:互联网 发布:淘宝卖家怎么做直播 编辑:程序博客网 时间:2024/06/05 10:43
link:http://www.cnblogs.com/kaituorensheng/archive/2013/02/28/2937865.html
typedef struct queue
{int queuesize; //数组的大小
int head, tail; //队列的头和尾下标
int *q; //数组头指针
}Queue;
{
q->queuesize = 8;
q->q = (int *)malloc(sizeof(int ) * q->queuesize); //分配内存
q->tail = 0;
q->head = 0;
}
{
int tail = (q->tail+1) % q->queuesize; //取余保证,当quil=queuesize-1时,再转回0
if (tail == q->head) //此时队列没有空间
{
printf("the queue has been filled full!");
}
else
{
q->q[q->tail] = key;
q->tail = tail;
}
}
int DeQueue(Queue *q)
{
int tmp=NULL;
if(q->tail == q->head) //判断队列不为空
{
printf("the queue is NULL\n");
}
else
{
tmp = q->q[q->head];
q->head = (q->head+1) % q->queuesize;
}
return tmp;
}
int IsQueueEmpty(Queue *q)
{
if(q->head == q->tail)
{
return 1;
}
else
{
return 0;
}
}
0 0
- 数据结构之队列(链式队列)
- 数据结构之队列(数组队列)
- 数据结构之队列-顺序队列
- 数据结构之循环队列
- 数据结构之顺序队列
- 数据结构之链队列
- java数据结构之队列
- 数据结构之队列
- 数据结构复习之【队列】
- 内核数据结构之队列
- 数据结构之队列实例
- 数据结构学习之队列
- 复习数据结构之队列
- C 队列之数据结构
- 基础数据结构之队列
- 数据结构之队列
- 大话数据结构之队列
- 数据结构之循环队列
- 哈他淘宝官方旗舰店无味瑜伽垫怎么样瑜伽垫质量好吗
- 陶瓷企业如何用好电子商务这把刀助力发展
- new 修饰符(msdn C# 参考)
- 电子商务和CRM相辅相成
- 《马云创业语录》——创业者就是要面对困难
- 数据结构之队列
- 10.Container With Most Water Leetcode Python
- 8dVASair max運動鞋台灣哪裡找 2JPf KzI
- 数据结构之AVLTree(04-1:Root of AVL Tree)
- Decode Ways - Leetcode
- poj 1125 最短路
- 基于经济学视角对我国职业教育起源进行探讨
- C#——调用exe程序并运行
- [Leetcode]Linked List Cycle II