实验目的
掌握队列的结构特性及其入队、出队的操作,掌握循环队列的特点及其操作。
实验内容和要求
要求实现栈的操作集。
函数接口定义
Status InitQueue(LinkQueue &Q);
Status EnQueue(LinkQueue &Q,QElemType e);
Status DeQueue(LinkQueue &Q,QElemType &e);
Status QueueLength(LinkQueue Q);
Status QueueTraverse(LinkQueue &Q,Status(visit)(QElemType));
int PrintElem(QElemType e);
Status QueueEmpty(LinkQueue Q);
Status GetHead(LinkQueue Q,QElemType &e);
Status ClearQueue(LinkQueue &Q);
Status DestoryQueue(LinkQueue &Q);
其中LinkQueue结构定义如下:
typedef struct QNode{
QElemType data;
struct QNode *next;
}QNode,*QueuePtr;
typedef struct{
QueuePtr front; // 头指针
QueuePtr rear; // 尾指针
}LinkQueue;
测试程序样例
int main(){
LinkQueue Q;//结构体Q