当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
unity-shader-2
让动画每次重复前都有延迟
loadrunner-controller-目标场景Schedule配置
loadrunner录制问题
&#x开头的是什么编码?
初识二叉搜索树
(C语言)程序环境和预处理
医院管理系统数据库,课程设计,SQLserver,纯代码设计
半个月时间把MySQL重新巩固了一遍,梳理了一篇几万字 “超硬核” 文章!
Redis的简单使用
Three ways of single sign-on
P5231 [JSOI2012]玄武密码(SAM 经典运用)
【GORM】存取数组/自定义类型数据
单点登录原理及实现方式
C#多态的实现
C#之泛型、委托、事件及其使用
Gradle series - Groovy overview, basic use (based on Groovy document 4.0.4) day2-1
SQL学习笔记——REGEXP运算符
Chapter Six
Come n times - 07. Rebuild the binary tree