当前位置:网站首页>双链表的创建
双链表的创建
2022-07-31 10:08:00 【柯基@】
- 尾插法
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;
}
}
边栏推荐
- Come n times with the sword--05. Replace spaces
- js以变量为键
- 如何判断自己是否适合IT行业?方法很简单
- NowCoderTOP17-22 Binary search/sort - continuous update ing
- Binary tree search and backtracking problem (leetcode)
- 湖仓一体电商项目(二):项目使用技术及版本和基础环境准备
- Source code analysis of GZIPInputStream class
- Simple understanding of GCD
- 使用turtle画按钮
- 感情危机,朋友的网恋女友要和他闹分手,问我怎么办
猜你喜欢
随机推荐
Day113.尚医通:用户认证、阿里云OSS、就诊人管理
出色的移动端用户验证
Web系统常见安全漏洞介绍及解决方案-XSS攻击
Come n times with the sword--05. Replace spaces
[ verb phrase ] collection
恋爱期间的赠与能否撤销
matlab 读取csv文件绘图
【LeetCode】387. 字符串中的第一个唯一字符
win10镜像下载
NowCoderTOP23-27 Binary tree traversal - continuous update ing
Emotional crisis, my friend's online dating girlfriend wants to break up with him, ask me what to do
Kotlin—基本语法(三)
使用turtle画按钮
Principle of Redis Sentinel
湖仓一体电商项目(二):项目使用技术及版本和基础环境准备
Mybaits 常用问题详解
js实现2020年元旦倒计时公告牌
js滚动条滚动到指定元素
梅科尔工作室--鸿蒙十四天开发培训笔记(八)
loadrunner-controller-场景执行run









