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

“chmod 777-R 文件名”什么意思?

第五章

The big-eyed Google Chrome has also betrayed, teach you a trick to quickly clear its own ads

Mybaits Frequently Asked Questions Explained

Kotlin—基本语法(三)

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

初识二叉搜索树

Web系统常见安全漏洞介绍及解决方案-CSRF攻击

(C语言)程序环境和预处理

darknet 训练分类网络
随机推荐
P5231 [JSOI2012]玄武密码(SAM 经典运用)
业务-(课程-章节-小节)+课程发布一些业务思路
NowCoderTOP17-22 二分查找/排序——持续更新ing
双链表的插入和删除
【LeetCode】36.有效的数独
&#x开头的是什么编码?
MySQL中JOIN的用法
透过开发抽奖小程序,体会创新与迭代
浅谈Attention与Self-Attention,一起感受注意力之美
金鱼哥RHCA回忆录:CL210管理OPENSTACK网络--开放虚拟网络(OVN)简介(课后练习)
Redis集群-哨兵模式原理(Sentinel)
Chapter VII
【GORM】存取数组/自定义类型数据
GZIPInputStream 类源码分析
SQLite3交叉编译
Three ways of single sign-on
【LeetCode】Day108-和为 K 的子数组
[ verb phrase ] collection
[ 动词词组 ] 合集
尚医通【预约挂号系统】总结