当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
模块八
SQL——左连接(Left join)、右连接(Right join)、内连接(Inner join)
【GORM】存取数组/自定义类型数据
Three ways of single sign-on
darknet 硬件软件环境的设置和检测
数据中台建设(六):数据体系建设
(C语言)程序环境和预处理
cocoaPods管理之后工程结构变化
Come n times - 09. Implement queues with two stacks
【LeetCode】21. 合并两个有序链表
SQL如何从字符串截取指定字符(LEFT、MID、RIGHT三大函数)
Build finished with errors/Executable Not Found
loadrunner-Controller负载测试-各模块功能记录01测试场景设计
第六章
Mysql+Navicat for Mysql
Source code analysis of GZIPInputStream class
js滚动条滚动到指定元素
双链表的插入和删除
NowCoderTOP23-27二叉树遍历——持续更新ing
SQL学习笔记——REGEXP运算符









