#include<iostream>
using namespace std;
#define ERROR 0
#define OK 1
typedef int Status;
typedef int QElemType;
typedef struct QNode
{
QElemType data;
struct QNode *next;
}QNode, *QueuePtr;
typedef struct
{
QueuePtr front;
QueuePtr rear;
}LinkQueue;
Status EndQueue(LinkQueue* Q, QElemType e)
{
QueuePtr s = (QueuePtr)malloc(sizeof(QNode));
if (!s)
{
return ERROR;
}
s->data = e;
s->next = NULL;
Q->rear->next = s;
Q->rear = s;
return OK;
}
Status DelQueue(LinkQueue *L, QElemType *e)
{
QueuePtr p;
if (L->rear == L->front)
{
return ERROR;
}
*e = L->front->data;
p = L->front->next;
L->front->next = p->next;
if (L->rear == p)
{
L->front = L->rear;
}
free(p);
return OK;
}
数据结构六—队列的链式存储结构
最新推荐文章于 2023-09-30 10:51:11 发布