当前位置:网站首页>Creation of doubly linked list
Creation of doubly linked list
2022-07-31 10:17:00 【[email protected]】
- 尾插法
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;
}
}
版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/212/202207311008455861.html
边栏推荐
猜你喜欢
随机推荐
Add a shuffling effect to every pie
Three ways of single sign-on
VMware下安装win10启动后进入Boot Manger界面如何解决
SQL力扣刷题五
NowCoderTOP23-27 Binary tree traversal - continuous update ing
loadrunner录制问题
怎样使用浏览器静默打印网页
【LeetCode】118.杨辉三角
Open Kylin openKylin automation developer platform officially released
数据中台建设(六):数据体系建设
如何将虚拟机上的文件复制到主机上
如何在 TiDB Cloud 上使用 Databricks 进行数据分析 | TiDB Cloud 使用指南
What is the encoding that starts with &#x?
富文本编辑器Tinymce
【GORM】存取数组/自定义类型数据
Come n times with the sword--05. Replace spaces
VMware下安装win10
What does "chmod 777-R filename" mean?
Chapter VII
Data Middle Office Construction (6): Data System Construction