当前位置:网站首页>双链表的创建
双链表的创建
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;
}
}
边栏推荐
- Scala basics [seq, set, map, tuple, WordCount, queue, parallel]
- Meikle Studio--Hongmeng 14-day development training notes (8)
- Centos7 install mysql5.7
- js implements the 2020 New Year's Day countdown bulletin board
- Solve rpc error: code = Unimplemented desc = method CheckLicense not implemented
- 如何将亚马逊广告添加到您的 WordPress 网站(3 种方法)
- P5231 [JSOI2012]玄武密码(SAM 经典运用)
- nodeJs--url模块
- (C语言)程序环境和预处理
- loadrunner录制问题
猜你喜欢
随机推荐
一些计时软件,生产力工具
loadrunner-controller-场景执行run
Mysql+Navicat for Mysql
postgresql generate random date, random time
Come n times with the sword--05. Replace spaces
OpenGL es 导读篇
第六章
OpenGL es 初识
Kotlin—基本语法 (五)
第二十四课、二十五课,高级光照(blinn),Gamma矫正
Kotlin入门介绍篇
【LeetCode】383.赎金信
如何在 TiDB Cloud 上使用 Databricks 进行数据分析 | TiDB Cloud 使用指南
Build finished with errors/Executable Not Found
湖仓一体电商项目(二):项目使用技术及版本和基础环境准备
Redis Cluster - Sentinel Mode Principle (Sentinel)
Gradle系列——Groovy概述,基础使用(基于Groovy文档4.0.4)day2-1
nodeJs--querystring模块
Kotlin—基本语法 (四)
NowCoderTOP17-22 Binary search/sort - continuous update ing









