当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
loadrunner-controller-目标场景Schedule配置
Deletion of the sequence table
SQL学习笔记——REGEXP运算符
Come n times - 07. Rebuild the binary tree
【GORM】存取数组/自定义类型数据
Redis Cluster - Sentinel Mode Principle (Sentinel)
初识二叉搜索树
Kotlin—基本语法(三)
力扣shell刷题
Echart饼图添加轮播效果
Mybaits 常用问题详解
我们能做出来数据库吗?
踩水坑2 数据超出long long
WEB核心【记录网站登录人数,记录用户名案例】Cookie技术实现
loadrunner录制问题
Build finished with errors/Executable Not Found
SQLServer2019安装(Windows)
js滚动条滚动到指定元素
Chapter Six
nodeJs--querystring模块









