当前位置:网站首页>双链表的创建
双链表的创建
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;
}
}
边栏推荐
- 前序、后序及层次遍历实现二叉树的序列化与反序列化
- centos7安装mysql5.7
- Day113. Shangyitong: user authentication, Alibaba Cloud OSS, patient management
- loadrunner-Controller负载测试-各模块功能记录01测试场景设计
- 出色的移动端用户验证
- ARC在编译和运行做了什么?
- loadrunner-controller-目标场景Schedule配置
- Redis集群-哨兵模式原理(Sentinel)
- 【LeetCode】203.移除链表元素
- js right dot single page scrolling introduction page
猜你喜欢
随机推荐
【LeetCode】Day108-和为 K 的子数组
湖仓一体电商项目(二):项目使用技术及版本和基础环境准备
实现线程池
PyQt5快速开发与实战 9.4 Matplotlib在PyQt中的应用
VMware下安装win10启动后进入Boot Manger界面如何解决
我们能做出来数据库吗?
Gradle series - Groovy overview, basic use (based on Groovy document 4.0.4) day2-1
SQLite3交叉编译
Come n times - 09. Implement queues with two stacks
Web系统常见安全漏洞介绍及解决方案-XSS攻击
自定义v-drag指令(横向拖拽滚动)
js滚动条滚动到指定元素
js implements the 2020 New Year's Day countdown bulletin board
Kotlin入门介绍篇
Redis Sentinel原理
Progressive Web App(PWA)
Redis Cluster - Sentinel Mode Principle (Sentinel)
Business-(Course-Chapter-Subsection) + Course Publishing Some Business Ideas
NowCoderTOP23-27二叉树遍历——持续更新ing
让动画每次重复前都有延迟