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

相关推荐
爱敲点代码的小哥38 分钟前
【无标题】
linux·windows·microsoft
GrowingYi41 分钟前
算法基础技术栈
数据结构·算法
bst@微胖子42 分钟前
CrewAI+FastAPI的Pipelines功能实现多CrewAI工作流以及Flows功能实现复杂工作流
服务器·windows·fastapi
吴声子夜歌1 小时前
数据结构与算法——排序
数据结构·算法·排序算法
wuk9981 小时前
C# Winform实现拼图游戏
windows·microsoft·c#
漫随流水9 小时前
leetcode算法(151.反转字符串中的单词)
数据结构·算法·leetcode
ada7_10 小时前
LeetCode(python)78.子集
开发语言·数据结构·python·算法·leetcode·职场和发展
十五年专注C++开发10 小时前
CMake进阶:vcpkg中OpenSSLConfig.cmake详解
c++·windows·cmake·openssl·跨平台编译
多多*13 小时前
2026年1月3日八股记录
java·开发语言·windows·tcp/ip·mybatis
nnsix14 小时前
Windows 将桌面 路径 从C盘 移动到D盘
windows