当前位置:网站首页>Creation of doubly linked list
Creation of doubly linked list
2022-07-31 10:17:00 【[email protected]】
- 尾插法
void createDlistR(DLNode *&L,int a[],int n){
DLNode *s,*r;
int i;
L=(DLNode*)malloc(sizeof(DLNode));
L->prior=NULL;
L->next=NULL;
r=L;
for(i=0;i<n;i++){
s=(DLNode*)malloc(sizeof(DLNode));
s->data=a[i];
r->next=s;
s->prior=r;
r=s;
}
r->next=NULL;
}
- 头插法
void createDlistR(DLNode *&L,int a[],int n){
DLNode *s;
int i;
L=(DLNode*)malloc(sizeof(DLNode));
L->prior=NULL;
L->next=NULL;
for(i=0;i<n;i++){
s=(DLNode*)malloc(sizeof(DLNode));
s->data=a[i];
s->next=L->next;
if(L->next!=NULL)
L->next->prior=s;
L->next=s;
s->prior=L;
}
}
原网站
版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/212/202207311008455861.html
边栏推荐
猜你喜欢
随机推荐
【JWT】JWT 整合
cocoaPods管理之后工程结构变化
【LeetCode】203.移除链表元素
A Method for Ensuring Data Consistency of Multi-Party Subsystems
The fifth chapter
湖仓一体电商项目(二):项目使用技术及版本和基础环境准备
数据中台建设(六):数据体系建设
ASP.NET 身份认证框架 Identity(一)
unity-shader-2
【LeetCode】36.有效的数独
Build finished with errors/Executable Not Found
SQL力扣刷题七
Day113.尚医通:用户认证、阿里云OSS、就诊人管理
NowCoderTOP17-22 二分查找/排序——持续更新ing
Solve rpc error: code = Unimplemented desc = method CheckLicense not implemented
逆置问题--重点
我们能做出来数据库吗?
前序、后序及层次遍历实现二叉树的序列化与反序列化
细讲DDD领域驱动设计
小程序如何使用订阅消息(PHP代码+小程序js代码)









