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

相关推荐
葵花日记16 分钟前
数据结构——二叉树
c语言·数据结构
九班长33 分钟前
Mirror的多人连接管理及房间系统
windows
一个懒鬼44 分钟前
Edge浏览器打开PDF文件显示空白(每次需要等上一会)
windows·pdf
越城1 小时前
数据结构中的栈与队列:原理、实现与应用
c语言·数据结构·算法
似水এ᭄往昔1 小时前
【数据结构】——栈和队列OJ
c语言·数据结构·c++
双叶8362 小时前
(C语言)超市管理系统(测试版)(指针)(数据结构)(二进制文件读写)
c语言·开发语言·数据结构·c++
com未来2 小时前
使用 NSSM 安装 Tomcat 11.0.6 为 Windows 服务
java·windows·tomcat
不要数手指啦3 小时前
Apifox使用方法
windows
想睡hhh4 小时前
c++进阶——哈希表的实现
开发语言·数据结构·c++·散列表·哈希
打鱼又晒网5 小时前
数据类型:List
数据结构·list