链队基本操作及打印杨辉三角

这篇博客介绍了如何使用链队数据结构进行基本操作,包括初始化、入队、出队和取对顶元素,并展示了如何利用链队来打印杨辉三角。博主通过示例代码详细解释了每个操作的过程,并提供了完整的链队实现杨辉三角的主程序。
摘要由CSDN通过智能技术生成
#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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值