C语言实现循环队列
SequenceQueue.h #pragma once #define ElemType char #define QuenueSize 5 #define ERROR -1 #define OVERFLOW -2 typedef struct SequenceQueue { ElemType* base; int front; int rear; int size; } Queue; void InitQueue(Queue& Q);//初始化队列 void DestroyQueue(Queue& Q);//销毁队列 void ClearQueue(Queue& Q);//清空队列 bool EmptyQueue(Queue Q);//判断队列是否为空 ElemType* GetFront(Queue Q);//获取队首元素 void EnQueue(Queue& Q, ElemType e);//入队 void DeQueue(Queue& Q, ElemType& e);//出队 int QueueLength(Queue Q);//获取队列长度 void QueueTraverse(Queue Q, void(*f)(ElemType e));//遍历队列 SequenceQueue.c #include <stdlib.h> #include <stdio.h>