/
//链队列
#include<iostream>
#include<malloc.h>
#define OK 1;
#define ERROR 0
#define TRUE 1
#define FALSE 0
#define OVERFLOW -2
typedef int QElemType;
typedef int Status;
using namespace std;
typedef struct QNode{
QElemType data;
QNode *next;
}*QueuePtr;
struct LinkQueue{
QueuePtr front,rear;
};
Status InitQueue(LinkQueue &Q)
{//初始化
if(!(Q.front=Q.rear=(QueuePtr)malloc(sizeof(QNode))))
exit(OVERFLOW);
Q.front->next=NULL;
return OK;
}
Status EnQueue(LinkQueue &Q,QElemType e)
{//入队列
QueuePtr p;
if(!(p=(QueuePtr)malloc(sizeof(QNode))))
exit(OVERFLOW);
p->data=e;
p->next=NULL;
Q.rear->next=p;
Q.rear=p;
return OK;
}
Status GetHead(LinkQueue Q,QElemType &e)
{//返回队头元素
QueuePtr p;
if(Q.front==Q.rear)
return ERROR;
p=Q.front->next;
e=p->data;
return OK;
}
Status DeQueue(LinkQueue &Q,QElemType &e)
{//删除队头元素
QueuePtr p;
if(Q.front==