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

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.dtcms.com/a/350330.html

相关文章:

  • UPROPERTY的再次学习
  • 高通SNPE测试:6、在开发板上运行Inception v3 Model(oe-linux)
  • vite + react + tailwind(2025-08-25)
  • C++贪吃蛇---详细步骤
  • 2.4 Flink运行时架构:Task、SubTask、ExecutionGraph的关系
  • OPcache 高级技术文档:原理、监控与优化实践
  • Unity使用Sprite切割大图
  • JavaScript 性能优化实战:从理论到落地的技术文章大纲
  • 基于长短期记忆网络的多变量时间序列预测 LSTM
  • Redis 哨兵 Sentinel
  • 【沉浸式解决问题】NVIDIA 显示设置不可用。 您当前未使用连接到NVIDIA GPU 的显示器。
  • 实时监测蒸汽疏水阀的工作状态的物联网实时监控平台技术解析
  • VLLM的加速原理
  • 基于MATLAB实现支持向量机(SVM)进行预测备
  • 大模型的多机多卡训练
  • 神经网络|(十五)概率论基础知识-协方差标准化和皮尔逊相关系数
  • 亚马逊AWD美西新仓上线:旺季备货的效率革命与策略升级
  • 真实应急响应案例记录
  • 机器学习笔记
  • Neumann Networks for Linear Inverse Problems in Imaging论文阅读
  • CF2133D 鸡骑士
  • 基于遗传算法优化BP神经网络的时间序列预测 GA-BP
  • PNP机器人介绍:全球知名具身智能/AI机器人实验室介绍之多伦多大学机器人研究所
  • DeepSeek 14B模型本地部署与预训练实现方案
  • jsvmp是什么,如何使用
  • 入门Ubuntu操作系统
  • 深度学习:从手写数字识别案例认识pytorch框架
  • 用 GSAP + ScrollTrigger 打造沉浸式视频滚动动画
  • 《零基础学 C 语言文件顺序读写:fputc/fgetc 到 fread/fwrite 函数详解》
  • 并行算法与向量化指令集的实战经验