目录
1.引入头文件
#include<stdio.h>
#include<stdlib.h>
2.存储结构
typedef struct QNode{
int data;
struct QNode *next;
}QNode,*QueuePtr;
typedef struct{
QueuePtr front;
QueuePtr rear;
}LinkQueue;
3.函数定义
3.1 建队列
//建队列
bool InitQueue(LinkQueue &Q){
Q.front = Q.rear = (QueuePtr)malloc(sizeof (QNode));
if(!Q.front)
return false;
Q.front->next = NULL;
return true;
}
3.2 销毁队列
//销毁队列
void DestroyQueue(LinkQueue &Q){
while(Q.front){
Q.rear = Q.front->next;
free(Q.fron