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

相关推荐
Fine姐2 分钟前
数据结构——02队列
数据结构
仰泳的熊猫10 分钟前
1176 The Closest Fibonacci Number
数据结构·c++·算法·pat考试
一条大祥脚14 分钟前
Cuda Rudece算子实现(附4090/h100测试)
java·数据结构·算法
2401_841495641 小时前
【LeetCode刷题】跳跃游戏
数据结构·python·算法·leetcode·游戏·贪心算法·数组
_w_z_j_2 小时前
全排列问题(包含重复数字与不可包含重复数字)
数据结构·算法·leetcode
@小码农2 小时前
LMCC大模型认证 青少年组 第一轮模拟样题
数据结构·人工智能·算法·蓝桥杯
sztomarch2 小时前
Windows-Commands-prompt
windows·prompt
CoderYanger3 小时前
A.每日一题——3606. 优惠券校验器
java·开发语言·数据结构·算法·leetcode
coderxiaohan3 小时前
【C++】哈希表实现
数据结构·哈希算法·散列表
CoderYanger3 小时前
D.二分查找-基础——744. 寻找比目标字母大的最小字母
java·开发语言·数据结构·算法·leetcode·职场和发展