
#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2
typedef int Status;
typedef int QElemType;
typedef struct QNode
{
QElemType data;
struct QNode *next;
}QNode, *QueuePtr;
typedef struct Queue
{
QueuePtr front;
QueuePtr rear;
}SqQueue;
Status InitQueue(SqQueue &Q)
{
Q.front = (QNode *)malloc(sizeof(QNode));
if(!Q.front) exit(OVERFLOW);
Q.front->next = NULL;
Q.rear = Q.front;
return OK;
}
Status DestroyQueue(SqQueue &Q)
{
QNode *p = Q.front, *postp;
while(p)
{
postp = p->next;
free(p);
p = postp;
}
Q.front = Q.rear = NULL