当前位置:网站首页>双链表的创建
双链表的创建
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;
}
}
边栏推荐
- 如何判断自己是否适合IT行业?方法很简单
- Binary tree search and backtracking problem (leetcode)
- P5231 [JSOI2012]玄武密码(SAM 经典运用)
- Source code analysis of GZIPInputStream class
- Build finished with errors/Executable Not Found
- Dart Log tool class
- 【TCP/IP】Network Model
- Emotional crisis, my friend's online dating girlfriend wants to break up with him, ask me what to do
- 比较并交换 (CAS) 原理
- Redis Sentinel原理
猜你喜欢
随机推荐
【LeetCode】203.移除链表元素
Data Middle Office Construction (6): Data System Construction
【LeetCode】383.赎金信
The big-eyed Google Chrome has also betrayed, teach you a trick to quickly clear its own ads
自定义v-drag指令(横向拖拽滚动)
作为面试官,关于线程池的问题我一般这样套路...
nodeJs--querystring模块
第二十四课、二十五课,高级光照(blinn),Gamma矫正
Open Kylin openKylin automation developer platform officially released
Redis的简单使用
OpenGL es 导读篇
【职场杂谈】售前工程师岗位的理解杂谈
Are postgresql range queries faster than index queries?
djangoWeb应用框架+MySQL数据4
loadrunner-controller-手动场景Schedule配置
Mysql+Navicat for Mysql
GCD简单了解
如何优雅的停止一个线程?
Meikle Studio--Hongmeng 14-day development training notes (8)
GVINS论文阅读笔记









