当前位置:网站首页>双链表的创建
双链表的创建
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;
}
}
边栏推荐
猜你喜欢

loadrunner-Controller负载测试-各模块功能记录01测试场景设计

centos7安装mysql5.7

乐观锁和悲观锁

第二十四课、二十五课,高级光照(blinn),Gamma矫正

Chapter VII

Day113. Shangyitong: user authentication, Alibaba Cloud OSS, patient management

Kotlin—基本语法 (四)

loadrunner-controller-场景执行run

Meikle Studio--Hongmeng 14-day development training notes (8)

js radar chart statistical chart plugin
随机推荐
NowCoderTOP17-22 二分查找/排序——持续更新ing
如何将亚马逊广告添加到您的 WordPress 网站(3 种方法)
【GORM】存取数组/自定义类型数据
第七章
如何将虚拟机上的文件复制到主机上
win10镜像下载
Chapter Six
Add a shuffling effect to every pie
A Spark SQL online problem troubleshooting and positioning
Open Kylin openKylin automation developer platform officially released
【LeetCode】Day108-和为 K 的子数组
postgresql generate random date, random time
一些计时软件,生产力工具
(C语言)程序环境和预处理
Source code analysis of GZIPInputStream class
NowCoderTOP28-34 binary tree - continuous update ing
解决rpc error: code = Unimplemented desc = method CheckLicense not implemented
细讲DDD领域驱动设计
Mybaits 常用问题详解
Flink1.15 source code reading - PER_JOB vs APPLICATION execution process