实验三、循环队列
来源:互联网 发布:驱赶苍蝇软件 编辑:程序博客网 时间:2024/05/22 12:15
入队操作:将队尾指针在循环意义上+1,然后将待插入元素插入队尾
出队操作:将队头指针在循环意义上+1,然后读取并返回
#includeusing namespace std;const int cd = 10;class cirqueue{public:cirqueue(){front = rear = cd - 1;}~cirqueue() {}void enqueue(int x);int dequeue();int get();void print();int empty(){return(front == rear) ? 1 : 0;}private:int data[cd];int front, rear;};void cirqueue::enqueue(int x){if ((rear + 1) % cd == front)throw"上溢";rear = (rear + 1) % cd;data[rear] = x;}int cirqueue::dequeue(){if (rear == front)throw"下溢";front = (front + 1) % cd;return data[front];}int cirqueue::get(){if (rear == front)throw"下溢";int i = (front + 1) % cd;cout << data[i] << endl;return 0;}void cirqueue::print(){for (int i = 0; i
阅读全文
0 0
- 实验三、循环队列
- 实验三循环队列(c++)
- 循环队列实验
- 循环队列实验3
- (实验三)《数据结构》第三章 循环队列与链队列验证
- 实验三 顺序队列
- 实验三 链队列
- 实验三链队列
- 实验三顺序队列
- 实验三 模拟饭堂排队打饭管理软件(循环队列实现)
- 实验三 栈和队列
- 实验三:栈和队列
- 实验三栈和队列
- 实验三 栈和队列
- 实验三 栈和队列
- 【实验三】栈和队列
- 实验三 栈和队列
- 实验三-栈和队列
- C#简单通用的进制转换,把非十进制的数据类型转换成十进制的,然后再转换成其他类型。
- Iterator和Iterable解析
- Android开发知识(七):Android事件处理机制:事件分发、传递、拦截、处理机制的原理分析(上)
- pandas groupby使用
- 洛谷P2066 机器分配
- 实验三、循环队列
- Zynq UltraScale+ MPSoC
- ie6下如何使得广告窗口不会因为滚动条的滚动而移动
- 【bzoj3238】[Ahoi2013]差异
- git跟新gitbub的代码(首次跟新步骤)
- 判断手机是android还是ios,是否用了微信内置浏览器
- filebeat常见配置项梳理
- 数据丢失不用怕 iPhone手机数据备份方法分享
- 解决IE8固定宽度下拉列表中option内容显示不全问题