队列的操作 队列的操作
发布时间
阅读量:
阅读量
/***循环队列基本操作***/
#include<iostream>
#include<fstream>
using namespace std;
#define MAXQSIZE 100
#define OK 1
#define ERROR 0
#define OVERFLOW -2
typedef char QElemType;
typedef char SElemType;
typedef int Status;
typedef struct {
QElemType *base;//初始化时动态分配存储空间
int front;//头指针
int rear;//尾指针
} SqQueue;
//算法 循环队列的初始化
Status InitQueue(SqQueue &Q) {//构造一个空队列Q
Q.base = new QElemType[MAXQSIZE]; //为队列分配一个最大容量为MAXSIZE的数组空间
if (!Q.base)
exit(OVERFLOW); //存储分配失败
Q.front = Q.rear = 0; /
全部评论 (0)
还没有任何评论哟~
