#include "stdio.h"
#include <malloc.h>
typedef struct Node/*结点类型定义*/
{
int data;
struct Node * next;
}LinkQueueNode;
typedef struct/*链队的类型定义*/
{
LinkQueueNode * front;
LinkQueueNode * rear;
}LinkQueue;
LinkQueue * init_LinkQueue(LinkQueue * Q)/*初始化*/
{
Q->front=(LinkQueueNode *)malloc(sizeof(LinkQueueNode));
if(Q->front!=NULL)
{
Q->rear=Q->front;
Q->front->next=NULL;
}
return Q;
}
void enter_LinkQueue(LinkQueue * Q,int data)/*入队*/
{
LinkQueueNode * temp=(LinkQueueNode *)malloc(sizeof(LinkQueueNode));
if(temp!=NULL)
{
temp->data=data;
temp->next=NULL;
Q->rear->next=temp;
Q->rear=temp;
}
}
int delete_LinkQueue(LinkQueue * Q)/*出队*/
{
LinkQueueNode * temp=(LinkQueueNode *)malloc(sizeof(LinkQueueNode));
if(Q->front==Q->rear)
{
return NULL;
}
temp=Q->front->next;
if(Q->front->next
链队基本操作及打印杨辉三角
最新推荐文章于 2022-05-02 13:58:03 发布
这篇博客介绍了如何使用链队数据结构进行基本操作,包括初始化、入队、出队和取对顶元素,并展示了如何利用链队来打印杨辉三角。博主通过示例代码详细解释了每个操作的过程,并提供了完整的链队实现杨辉三角的主程序。
摘要由CSDN通过智能技术生成