数据结构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

相关推荐
几道之旅20 小时前
我错了,mklink /D _isaac_sim C:\isaacsim和直接新建快捷方式原来不一样
windows
CoderCodingNo20 小时前
【GESP】C++六级考试大纲知识点梳理, (3) 哈夫曼编码与格雷码
开发语言·数据结构·c++
牛马大师兄20 小时前
数据结构复习 | 什么是数据结构?
数据结构
鹿角片ljp21 小时前
Java IO流案例:使用缓冲流恢复《出师表》文章顺序
java·开发语言·windows
wu_asia21 小时前
方阵对角线元素乘积计算
数据结构·算法
想逃离铁厂的老铁1 天前
Day43 >> 300.最长递增子序列 + 674. 最长连续递增序列+ 718. 最长重复子数组
数据结构·算法
FL16238631291 天前
[C++][cmake]基于C++在windows上onnxruntime+opencv部署yolo26-seg的实例分割onnx模型
c++·windows·opencv
宵时待雨1 天前
数据结构(初阶)笔记归纳4:单链表的实现
c语言·开发语言·数据结构·笔记·算法
wm10431 天前
代码随想录第三天 链表
数据结构·链表
非凡ghost1 天前
SoftPerfect Network Scanner(网络扫描管理工具)
网络·windows·学习·软件需求