头文件:函数的声明
#include <stdio.h>
#include <stdlib.h>
#define QUEUESIZE 100
typedef char ElemType;
typedef struct
{
ElemType queue[QUEUESIZE];
int front;
int rear;
int tag;//标志位(入队列成功tag = 1,出队列成功tag = 0)
}SCQueue;
void InitQueue(SCQueue *SCQ);//将顺序队初始化
int QueueEmpty(SCQueue SCQ);//判断顺序队是否为空
int EnQueue(SCQueue *SCQ,ElemType e);//将元素e插入队列队尾
int DeQueue(SCQueue *SCQ,ElemType *e);//删除对头元素
void DisplayQueue(SCQueue SCQ);//输出队列
int Gethead(SCQueue SCQ,ElemType *e);//获取队头元素
void ClearQueue(SCQueue *SCQ);//清空队列
函数的定义
#include "循环队列.h"
void InitQueue(SCQueue *SCQ)
{
SCQ->front = SCQ->rear = 0;
SCQ->tag = 0;//标志位初始化
}
int QueueEmpty(SCQueue SCQ)
{
if(SCQ.front == SCQ.rear && SCQ.tag == 0)
{
return 1;
}
else
{
return 0;
}
}
int EnQueue(SCQueue *SCQ,ElemType e)
{
if(SCQ->front == SCQ->rear && SCQ->