数据结构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 分钟前
闰年判断:C语言实战解析
c语言·数据结构·算法·新人首发
香蕉鼠片1 小时前
跨平台开发到底是什么
linux·windows·macos
木子墨5161 小时前
LeetCode 热题 100 精讲 | 并查集篇:最长连续序列 · 岛屿数量 · 省份数量 · 冗余连接 · 等式方程的可满足性
数据结构·c++·算法·leetcode
2501_921960852 小时前
双相自指图与弦论边界非对易性的结构同源
数据结构
Liangwei Lin2 小时前
洛谷 P3133 [USACO16JAN] Radio Contact G
数据结构·算法
心一信息3 小时前
Windows 计算机管理 · 事件日志完整运维指南
windows
锅挤5 小时前
数据结构复习(第五章):树与二叉树
数据结构
杨凯凡6 小时前
【014】基本类型与包装类:缓存、相等性、NPE
java·数据结构·缓存
故事和你916 小时前
洛谷-算法1-7-搜索3
数据结构·c++·算法·leetcode·动态规划
想唱rap6 小时前
C++智能指针
linux·jvm·数据结构·c++·mysql·ubuntu·bash