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

相关推荐
console.log('npc')34 分钟前
Windows 11 安装 WSL2 + Ubuntu + Docker + Codex + Sub2API 教学
windows·docker·powershell·ubantu·codex
谙弆悕博士6 小时前
【附C源码】从零实现C语言堆数据结构:原理、实现与应用
c语言·数据结构·算法··数据结构与算法
Mr_hwt_12312 小时前
Windows安装Claude Code详细教程(含apikey配置)
windows·ai编程·claude code
Languorous.12 小时前
Windows 安装 Linux 虚拟机 / WSL 完整教程(新手零失败)
linux·运维·windows
郭龙飞98012 小时前
OpenClaw技能拓展教程 五大场景高效办公实操指南
人工智能·windows·语言模型
小鹿软件办公13 小时前
在 Windows 中什么是 iphlpsvc?禁用它安全吗?
windows·安全·iphlpsvc
诸神缄默不语14 小时前
DNS 与 hosts 文件:Windows 11 中的名称解析配置
windows·计算机网络·dns·hosts
smj2302_7968265215 小时前
解决leetcode第3934题最短唯一子数组
数据结构·python·算法·leetcode
iiiiyu15 小时前
面向对象和集合编程题
java·开发语言·前端·数据结构·算法·编程语言
变量未定义~15 小时前
最长回文子串
数据结构·算法