// Filename : list_queue.c
// Author : LupingChen
// Data : 2015.05.30
// Content : create\destory\full\empty\push
#include <stadio.h>
#include <stdlib.h>
//定义节点数据类型
typedef struct Node {
int data;//数据
struct Node* next;//记录下一节点地址
} Node;
//定义队列数据类型
typedef struct {
Node* head;//头指针
} Queue;
//判断队列是否为满
int full(Queue* pq);
//判断队列是否为空
int empty(Queue* pq);
//入队
void push(Queue* pq, data);
//遍历
void travel(Queue* pq);
int main()
{
//创建,系统销毁
Queue queue;
queue.head= NULL;
return 0;
}
//判断队列是否为满
int full(Queue* pq)
{
return 0;
}
//判断队列是否为空
int empty(Queue* pq)
{
return NULL == pq->head;
}
//入队
void push(Queue* pq, data)
{
//创建节点
Node* pn = (Node* )malloc(sizeof(Node));
pn->data = data;
pn->next = NULL;
//挂载节点
//空队列挂载
if (empty)
{
pq->head = pn;
}
//非空队列挂载
Node* p = pq->head;
while (p->next != NULL)
{
p = p->next;
}
p->next = pn;
}
//遍历
void travel(Queue* pq)
{
printf("队列中元素有:");
Node* p = pq->head;
while (p != NULL)
{
printf("%d ", p->data);
p = p->next;
}
printf("\n");
}
队列的链式存储结构的实现1 —— 创建销毁判断满空入队
最新推荐文章于 2025-01-02 21:42:39 发布