当前位置:网站首页>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
边栏推荐
猜你喜欢

darknet 源码阅读笔记-01-activation_kernels.cu

Web系统常见安全漏洞介绍及解决方案-sql注入

Kotlin—基本语法(三)

DC-7-vulnhub

梅科尔工作室--鸿蒙十四天开发培训笔记(八)

NowCoderTOP28-34二叉树——持续更新ing

Come n times - 07. Rebuild the binary tree

Emotional crisis, my friend's online dating girlfriend wants to break up with him, ask me what to do

csdn file export to pdf

Sql优化总结!详细!(2021最新面试必问)
随机推荐
使用turtle画按钮
出色的移动端用户验证
P5231 [JSOI2012]玄武密码(SAM 经典运用)
【GORM】存取数组/自定义类型数据
Echart饼图添加轮播效果
Redis Cluster - Sentinel Mode Principle (Sentinel)
一种用于保证多方子系统数据一致性的方法
&#x开头的是什么编码?
细讲DDD领域驱动设计
力扣shell刷题
Implement a thread pool
踩水坑2 数据超出long long
【LeetCode】141.环形链表
Mybaits Frequently Asked Questions Explained
恋爱期间的赠与能否撤销
NowCoderTOP17-22 二分查找/排序——持续更新ing
[ verb phrase ] collection
(C语言)程序环境和预处理
Business-(Course-Chapter-Subsection) + Course Publishing Some Business Ideas
迪拜的超市---线段树双重懒标记+二分