数据结构2月25日

第一道:

第二道:

1、插入到prev和next中间

1.new=(struct list_head*)malloc(sizeof(struct list_head*));

if(new==NULL)

{

printf("失败\n");

return;

}

new->next=prev->next;

prev->next=new;

return;

2、删除prve和next中间那个

2.struct list_head* p=prev->next;

prev->next=p->next;

p->next->prev=prev;

free(temp);

temp=NULL;

return;

插入到队尾

  1. struct list_head3* temp = (struct list_head*)malloc(sizeof(struct list_head*));

if(temp==NULL)

{

printf("结点申请失败,插入失败\n");

return;

}

struct list_head* p=head;

while(p->next!=NULL)

{

p=p->next;

}

temp->next=NULL;

p->next=temp;

temp->prev=p;

return;

  1. entry->next->prev=entry->prev;

entry->prev->next=entry->next;

free(entry);

entry=NULL;

return;

判断是否为空

  1. if(head->next==NULL)

{

printf("链表为空\n");

}

return;


版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原文链接:https://blog.csdn.net/m0_67565143/article/details/136286971

相关推荐
努力写代码的熊大2 分钟前
单链表和双向链表
数据结构·链表
Orlando cron1 小时前
数据结构入门:链表
数据结构·算法·链表
qq_393828222 小时前
电脑休眠设置
windows·电脑·软件需求
网安小白的进阶之路5 小时前
A模块 系统与网络安全 第三门课 网络通信原理-3
网络·windows·安全·web安全·系统安全
许愿与你永世安宁6 小时前
力扣343 整数拆分
数据结构·算法·leetcode
Heartoxx6 小时前
c语言-指针(数组)练习2
c语言·数据结构·算法
杰克尼8 小时前
1. 两数之和 (leetcode)
数据结构·算法·leetcode
芳草萋萋鹦鹉洲哦12 小时前
【vue3+tauri+rust】如何实现下载文件mac+windows
windows·macos·rust
李洋-蛟龙腾飞公司12 小时前
HarmonyOS NEXT应用元服务常见列表操作多类型列表项场景
windows
学不动CV了17 小时前
数据结构---线性表理解(一)
数据结构