#include <stdio.h>
#include <stdlib.h>
#define OK 1
#define TRUE 1
#define ERROR 0
#define FALSE 0
#define MAXQSIZE 1000
typedef struct elem {
int n;
}elem;
typedef struct Qnode {
elem data;
Qnode* nest;
}Qnode,*QueuePtr;
typedef struct {
QueuePtr front;
QueuePtr rear;
}LinkQueue;
int InitQueue(LinkQueue &Q) {
Q.front = Q.rear = (QueuePtr)malloc(sizeof(Qnode));
Q.front->nest = NULL;
Q.rear->nest = NULL;
if (Q.front == NULL) return ERROR;
return OK;
}
int DestoryQueue(LinkQueue &Q) {
if (!Q.front) return ERROR;
QueuePtr p;
while (Q.front) {
p = Q.front->nest;
free(Q.front);
Q.front = p;
}
return OK;
}
int AddQueue(LinkQueue &Q, elem* e) {
if (!Q.front) return ERROR;
QueuePtr p = (QueuePtr)malloc(sizeof(Qnode));
if (!p) return ERROR;
p->data = *e;
p->nest = Q.rear->nest;
Q.rear->nest = p;
Q.rear = p;
return OK;
}
int DeleteQueue(LinkQueue &Q, elem* e) {
if (!Q.front || !Q.front->nest) return ERROR;
QueuePtr p = Q.front->nest;
Q.front->nest = p->nest;
*e = p->data;
free(p);
if (!Q.front->nest) {
Q.rear = Q.front;
}
return OK;
}
int GetTop(LinkQueue &Q, elem* e) {
if (!Q.front || !Q.front->nest) return ERROR;
*e = Q.front->nest->data;
return OK;
}
int main()
{
return 0;
}