//队列的链表实现
#include "stdafx.h"
#include <malloc.h>
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERR 0
typedef int QElemType;
typedef int Status;
typedef struct QNode_tag
{
QElemType data;
struct QNode_tag *next;
}QNode,*QueuePtr;
typedef struct
{
QueuePtr front; /*队列头指针*/
QueuePtr rear; /*队列尾指针*/
}LinkQueue;
/************************************************************************/
/*构造一个空队列 */
/************************************************************************/
Status InitQueue(LinkQueue *Q)
{
if(NULL == Q)
{
return ERR;
}
Q->front = Q->rear = (QueuePtr)malloc(sizeof(QNode));
if(NULL == Q->front)
{
return ERR;/*内存分配失败,生成头结点失败*/
}
Q->front->next = NULL;
return OK;
}
/************************************************************************/
/* 销毁队列Q
队列的链表实现
最新推荐文章于 2024-04-10 00:05:08 发布