双向链表的建立和反序

C语言实现双向链表删除节点、插入节点、双向输出等操作 #include #include typedef struct DoubleLinkedList { int data; struct DoubleLinkedList *pre; struct DoubleLinkedList *next; }DlinkedList_Node; //建立链表 DlinkedList_Node* createDLink() { D 阅读详情

链表以前一直没有自己手写过,发现程序这个东西,一定的自己动手练习,才会掌握的比较牢固。所以今天就自己动手写了双向链表的建立和反序。记录一下

#include <stdio.h>
#include <malloc.h>
typedef struct _node
{
int data;
struct _node *pre;
struct _node *next;
}Node,*pNode;
pNode head = NULL;
void creatHead()
{
  int temp;
  pNode pnode;
  if(head == NULL)
  {
  pnode = (Node *)malloc(sizeof(Node));
  pnode->data = 100;
  pnode->pre = NULL;
  pnode->next = NULL;
  head = pnode;
  }
  for(temp = 0;temp < 5;temp++)
  {
  pNode tempnode = (Node *)malloc(sizeof(Node));
  tempnode->data = temp;
  tempnode->pre = pnode;
  tempnode->next = NULL;
  pnode->next = tempnode;
  pnode = tempnode;
  }
}
void fanzhuan(pNode headnode)
{
  pNode prenode = NULL;
  pNode pnext = NULL;
  pNode pnode = headnode;
  while(pnode)
  {
  pnext = pnode->next;
  if(pnext == NULL)
  {
  head = pnode;
  pnode->pre = NULL;
  }
  pnode->next = prenode;
  pnode->pre = pnext;
  prenode = pnode;
  pnode = pnext;
  }
}
void printnode(pNode headnode)
{
  pNode pnode;
  pnode = headnode;
  while(pnode)
  { 
  printf("node data=%d\n",pnode->data);
  pnode = pnode->next;
  }
}
void main()
{
creatHead();
printnode(head);
fanzhuan(head);
printnode(head);
}

双向链表的C++实现 双向链表的C++实现           双向链表与单向链表相比,各个结点多了一个指向前一个结点的指针。结构如图所示:           双向链表的结点定义如下: #ifndef SIMPLENODE_HPP #define SIMPLENODE_HPP template //再定义一个模板 写双链表 class DoubleNode { public: 阅读详情

相关推荐

数据结构之---c语言实现双向链表操作

数据结构之---c语言实现双向链表操作

杨鑫newlife的专栏 2399

单链表和双链表逆序

本篇主要介绍了,单链表和双链表的概念,以及单链表和双链表的反转逆序逻辑,双链表相比于单链表多了一个前向指针的概念。在做双链表逆序的时候要考虑前向指针pre的处理。

橙子的随笔集 444

双链表反序(链表)

双链表定义 typedef struct _dNode { int data; struct _dNode *pre; struct _dNode *next; }DNode; 反序 int ReverseDoubleList(DNode * h) { if(!h || !h->next) { printf("DLinkedNode:...

thinker 556

逆序操作专题03——双向链表的逆序操作(面试题编程)

参考 博文01:https://blog.youkuaiyun.com/shltsh/article/details/46486945 博文02:https://blog.youkuaiyun.com/qiao_yuzhou/article/details/6165969 博文03:https://blog.youkuaiyun.com/autumn20080101/article/details/7607148 一、C语言实现(博...

博雅勇士的博客 1147

实现双向链表反转

基于linkedList实现自己的双向链表反转。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

双向链表的创建、逆序、删除

双向链表的创建、逆序、删除。附件是vs2008编译的工程,自己调试通过的。

双链表逆序

双链表之逆序 一、结点结构 &nbsp; &nbsp; &nbsp; &nbsp; 双向链表的数据结构定义如下: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; typedef struct node &nbsp;&nbsp;&nbs

qinglongzhan的博客 4596

PX4实战指南:通过遥控器通道直连实现舵机PWM控制

本文详细介绍了如何通过PX4飞控实现遥控器通道直连控制舵机PWM输出的完整流程。从硬件准备、遥控器配对到PX4参数配置和硬件连接,提供了实战技巧和常见问题解决方案,帮助无人机爱好者快速掌握舵机控制技术。重点讲解了AUX Passthrough模式设置和PWM参数调整等关键步骤。

weixin_29195217的博客 154

双向链表的反转算法

在双向链表中使用尾插法速度是非常快的,达到了O(1)级别,因为链表内部维护了一个tail属性,指向了最后一个元素,那么在插入的时候直接将tail指向的尾节点重新指向新插入的节点,新插入的节点再和原尾节点指向的节点做双向关联即可. 算法一 public void reverse(){ TowWayList<T> list = new TowWayList<>(); for(int i = length - 1;i >= 0;i++){ list.add(getNode

qq_43750656的博客 3094

IEPE传感器4mA恒流源接口电路

另外传感器的偏置电压大概在10V多点,一般接个电容把直流分量去掉。这里我们要把恒流源的电流设置在4毫安左右,R1取33Ω差不多正好。经过CR的隔直流电路后的波形是这样的。

老白的博客 6112

【仿真】Carla Python API实战:从零搭建自动驾驶测试环境

本文详细介绍了如何使用Carla Python API从零搭建自动驾驶测试环境。通过Carla仿真平台,开发者可以构建高度逼真的城市环境和车辆物理模型,利用Python API实现传感器配置、数据采集、场景构建及自动驾驶算法集成。文章还分享了实际项目中的调试技巧和性能优化经验,帮助读者快速掌握自动驾驶仿真测试的核心技术。

weixin_29050513的博客 213

C语言实现双向链表和仿STL迭代器

私有的userdata在公共的linklist的基础上进行实现,并通过将link_list_node作为结构体的第一个元素,来方便实现运行时的结构体地址转换。队列数据结构的一个基本实现方式是使用双向链表进行实现。本文展示了一种在C语言中实现双向链表,以及参考C++ STL的操作接口实现迭代器接口。先从使用示例开始,其中引用的linklist是公共实现,userdata是私有实现。链表的头文件声明,依次是迭代器接口、创建链表和结点的接口、销毁接口。另外按照链表的迭代器接口,实现顺序访问链表、反向访问链表。

选择的专栏 670

运用AD进行stm32最小系统PCB图的绘制

运用AD进行stm32最小系统PCB图的绘制一、PCB图的绘制(1)布局(2)布线(3)覆铜(4)电气规则检查二、给PCB添加logo三、生成garber文件总结 一、PCB图的绘制 (1)布局 1.画好原理图后,新建一个PCB项目 2.在Design中选择第二项,导入器件 3.先点击右下角第一项,再点第二项导入器件 导入成功 4.导入后效果 选择紫红色方框,按电脑上的delete键把它删掉 5.在Tools选择Outside Board,自动排布器件 排布后效果如图 6.画线,确定板子范围

lucario1的博客 2149

【算法题】记一道实现双向链表添加、删除、反序的算法题

记一次高人指点的数据结构(双向链表)

7zwang的博客 356

使用AutoDL云服务器训练YOLO计算机视觉网络模型(AutoDL+Xftp+VS Code),附详细操作步骤

AutoDL AI算力云是一个提供人工智能算力服务的云平台。丰富的GPU资源:提供多种GPU型号,包括NVIDIA的A100A800L40V100RTX 4090RTX 3090等,能满足我们在不同场景下的需求,无论是进行大规模的AI训练还是复杂的科学计算等任务,都可以找到合适的GPU资源。灵活的付费方式:支持按量付费包日包周包月等多种付费模式。对于短期的实验或不确定时长的项目,可以选择按量付费;如果有长期稳定的算力需求,预付费或包周包月则可能更划算,可以根据自己的需求和预算进行选择。集成主流框架:集成了。

Limiiiing的博客 958

Python 实战:爬取高德地图交通数据(路况拥堵指数分析)

高德地图是由高德软件有限公司开发的一款地图导航产品,提供详细的地图浏览、路线规划、实时路况、公共交通查询等功能。高德地图拥有庞大的用户群体和海量的交通数据,这些数据对于交通管理、城市规划、出行服务等领域具有重要的价值。通过对高德地图交通数据的分析,我们可以了解城市交通的运行状况,识别拥堵路段,预测交通流量,为交通管理部门和出行者提供决策支持。

yansideyucsdn的博客 2685

C语言实现双向链表(附带源码)

C语言实现双向链表(附带源码)

欢迎来到我的博客!这里是一个专注于计算机技术的分享平台,涵盖编程开发、算法研究、系统架构、软件工程等多个领域。无论你是初学者还是资深开发者,都能在这里找到有价值的内容。 1924

手把手入门YOLO到改进优化教程 | 【P2基础篇】数据标注+环境搭建+模型训练

本节以 YOLO自定义目标检测训练为主线,带你从零开始完成 数据标注 → 环境搭建 → 模型训练 → 结果的流程。使用labelImg制作符合YOLO格式的自定义数据集。在Windows基于 Python + Conda 创建独立虚拟环境,安装 PyTorch + CUDA + ultralytics,配置 PyCharm 运行环境。本节不仅使用自定义数据集进行演示,同时也用公开数据集训练 YOLO,查看训练日志与可视化结果(PR、P/R/F1 曲线等)等。

嵌入式阿齐Archie 2万+

数据结构链表之双向链表:Python3 实现双向链表——2

Python3 实现双向链表 双向链表 定义:双向链表是链表中的一种,双向链表也叫双链表,它由多个节点组成,每个节点由一个数据域和两个指针域组成,一个指针指向前驱元素,一个指向后继元素 双向链表一般用来构造循环链表,这个后面我们也会学习到 定义简单的双向链表 class Node: """The nodes of double linked list""" def __ini...

Moelimoe的博客 623

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

双向链表的基本操作

双向链表的插入顺序: 双向链表的删除顺序: #include #include typedef struct doubleLink { int data; struct doubleLink *pre; struct doubleLink *next; }dnode; //建立链表 dnode* create

acm_JL的博客 4618

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

c语言双链表删除节点,C语言实现双向链表删除节点、插入节点、双向输出等操作...

#include#includetypedef struct DoubleLinkedList{int data;struct DoubleLinkedList *pre;struct DoubleLinkedList *next;}DlinkedList_Node;//建立链表DlinkedList_Node* createDLink(){DlinkedList_Node *head,*p,*s...

weixin_35070925的博客 1488

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

复杂链表的复制(深拷贝)|| 二叉树转换成双向循环链表 || 序列化和反序列化二叉树

1.复杂链表的复制 深拷贝:复制后创建一个相同的对象,新对象与原对象不共享内存,修改新对象不会改变原对象。 浅拷贝:只复制指向某个对象的指针,并不复制对象本身,新对象与原对象仍共享同一块内存,当改变新对象值,原对象值也会改变。 请实现 copyRandomList 函数,复制一个复杂链表。在复杂链表中,每个节点除了有一个 next 指针指向下一个节点,还有一个 random 指针指向链表中的任意节点或者 null。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/

叨叨的博客 479

双向链表的查找、删除、插入节点

双向链表前插入无需定位到节点的前一位,因为其本身有prior指针。从根本上来讲,它和单链表是类似的:#include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; typedef struct student { int num; struct student *next; struct student *prior; }LDstudent...

IT8343的博客 5587

循环链表和双向链表浅析

循环链表和双向链表浅析

qq_42108074的博客 765

双向循环链表的C++实现

双向循环链表的C++实现

mourinho_my_idol的专栏 2550
上一篇: 新年开始,定个目标
下一篇: 单链表的建立,反序,插入,删除
devil27
博客等级 码龄19年 1粉丝 18原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值