当前位置: 首页 > backend >正文

8月25日

#include "head.h"

//1通过创建头节点创建双向链表
node_p creat_double_list_head_node()
{
node_p H=(node_p)malloc(sizeof(NODE));
if(H==NULL)
{
return NULL;
}
H->len=0;
H->next=NULL;
H->pri=NULL;
return H;
}
//创建普通数据节点
node_p create_data_node(int data)
{
node_p P= (node_p)malloc(sizeof(NODE));
if(S==NULL){return NULL;}
P->data = data;
P->pri = NULL;
P->next = NULL;
return P;
}
//3、判NULL空
int empty(node_p H)
{
if(H==NULL){return -1;}
return H->next==NULL;
}
//头插
void insert_head(node_p H,int value)
{
node_p new=create_data_node(value);
new->next=H->next;
new->pri=H;
if(H->next!=NULL)
{
H->next->pri=new;
}
H->next=new;
H->len++;
}
//尾插
void insert_tail(node_p H,int value)
{
node_p P=H;
while(P->next!=NULL)
{
P->next;
}
node_p new=create_data_node(value);
new->pri=P;
P->next=new;
H->len++;
}
//输出
void output(node_p H)
{
node_p P=H->next;
while(P)
{
printf("%d->",P->data);
P->next;
}
printf("NULL\n");
}
//头删
int  delete_head(node_p H)
{
if(H==NULL||H->next==NULL)
{
return -1;
}
node_p del=H->next;
H->next=del->next;
if(del->next!=NULL)
{
del->next->prev=H;
}
free(del);del=NULL;
head->len--;
return 0;
}
//尾删
int delete_tail(node_p H)
{
if(H==NULL||H->next==NULL)
{
return -1;
}
node_p P=H;
while(P->next!=NULL)
{
P=P->next;
}
P->prev->next=NULL;
free(P);
P=NULL;
H->len--;
return 0
}
//任意位置插入
int insert_pos(node_p H,int pos,int data)
{
if(H==NULL||pos<1||pos>H->len+1)
{
return -1;
}
node_p P=H;
for(int i=0;i<pos-1;i++)
{
P=P->next;
}
node_p new=create_data_node(data);
if(new==NULL)
{
return -1;
}
new->next=P->next;
new->prev=P;
if(P->next!=NULL)
{
P->next->prev=new;
}
P->next=new;
H->len++;
return 0;
}
//按位置删除
int delete_pos(int pos,node_p H)
{
if(H==NULL||H-next==NULL||pos<1||pos>head->len)
{
return -1;
}
node_p P=H;
//找pos-1位置
for(int i=0;i<pos-1;i++)
{
P=P->next;
}
node_p del=P->next;
P->next=del->next;
if(del->next!=NULL)
{
del->next->prev=del->prev;
}
head->len--;
return 0;
}
//按值查找位置
int seach_value(int value,node_p H)
{
if(H==NULL||H->next==NULL||pos<1||pos>H->len)
{
return -1;
}
node_p P=H;
int pos=0;
while(P->data!=value)
{
P=P->next;
pos++;
}
return pos;

}
//按位置修改
int update_pos(int pos,int value,node_p H)
{
if(NULL==H || H->next==NULL|| pos<1 || pos>head->len)
{
return -1;
}
node_p P=H;
for(int i=0;i<pos;i++)
{
P=P->next;
}
P->data=value;
return 0;
}


http://www.xdnf.cn/news/18704.html

相关文章:

  • 专题:2025人工智能2.0智能体驱动ERP、生成式AI经济现状落地报告|附400+份报告PDF、原数据表汇总下载
  • [论文阅读]RQ-RAG: Learning to Refine Queries for Retrieval Augmented Generation
  • k8s的etcd备份脚本
  • AR技术赋能农业机械智能运维
  • 电机控制::基于编码器的速度计算与滤波::RLS
  • 【C++】第二十六节—C++11(中) | 右值引用和移动语义(续集)+lambda
  • Linux_用 `ps` 按进程名过滤线程,以及用 `pkill` 按进程名安全杀进程
  • 机器学习-大语言模型Finetuning vs. Prompting
  • 大型语言模型基准测试综述《A Survey on Large Language Model Benchmarks.pdf》核心内容总结
  • 京东前端社招面经
  • 多维度指标交叉计算查询方案
  • 【芯片后端设计的灵魂:Placement的作用与重要性】
  • 6、RocketMQ消息积压问题如何解决
  • Python爬虫实战:Selenium模拟操作爬取马蜂窝旅游攻略
  • 数据挖掘 6.1 其他降维方法(不是很重要)
  • redis----list详解
  • 深度学习入门第一课——神经网络实现手写数字识别
  • 读《精益数据分析》:A/B测试与多变量测试
  • 【栈 - LeetCode】739.每日温度
  • [Java恶补day51] 46. 全排列
  • 无人机芯片休眠模式解析
  • 关于传统的JavaWeb(Servlet+Mybatis)项目部署Tomcat后的跨域问题解决方案
  • 日语学习-日语知识点小记-构建基础-JLPT-N3阶段(19):文法复习+单词第7回1
  • 基于知识图谱的装备健康智能维护系统KGPHMAgent
  • C++ #pragma
  • 少儿舞蹈小程序需求规格说明书
  • 【Hot100】二分查找
  • Fluent Bit系列:字符集转码测试(上)
  • 使用 Prometheus 监控服务器节点:Node Exporter 详解与配置
  • 实时监测蒸汽疏水阀的工作状态的物联网实时监控平台技术解析