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

专做PPP项目网站沈阳seo优化新势力

专做PPP项目网站,沈阳seo优化新势力,社交app定制开发,关键词排名优化易下拉技术目录 目录 前言 正文 链表定义: 基本创建链表程序: 链表结点插入: 对角线记忆法: 画图理解法: 链表结点删除: 链表销毁: 后语 前言 链表理解方法分享,愿你的大脑也能建立一个…

目录

       

目录

前言

正文

链表定义:

基本创建链表程序:

链表结点插入:

 对角线记忆法:

画图理解法:

链表结点删除:

链表销毁:

  后语



前言

        链表理解方法分享,愿你的大脑也能建立一个链表的指针!


正文

链表定义:

为什么要熟悉定义,总感觉对理解链表会有帮助的。
链表是什么?链表是C 高级编程核心。高级编程诶,开不开心!

链表是相对数组而言的,之所以需要链表是因为数组有缺点。

对于链表而言,最要命的其实不是庞大的代码量,而是逻辑。(就像接电路一样,搞不懂逻辑,看别人继电器之间互锁自锁,就像给自己大脑上了一把锁)

链表是N个结点离散分配,彼此通过指针相连,除头结点与尾结点外,中间的每个结点只有一个前去结点和一个后续结点, 头结点没有前驱结点,尾结点没有后续结点。

一堆鬼文字只能辅助理解(大部分摘自《手把手教你C语言》)。

基本创建链表程序:

就像当初学编程从输出“hello,world”一样,理解创建链表的过程很重要,是基础中的基础,这个搞定后,后面的一系列删除、插入等就不是问题了(的确没那么难理解了)。

//#define NDEBUG#include <stdio.h>
#include <stdlib.h>#include "dbg.h"typedef struct node{char *data;struct node  *next;
}Sn;//结构体类型通常首字母大写。
Sn *create_list(void); 
void print(Sn *list);int main(int argc, char *argv[])
{Sn *list;list = create_list();print(list);while(list !=NULL){Sn *tmp = list;list = list->next;free(tmp);}return 0;
}Sn *create_list(void)
{int i;int num;Sn *head = malloc(sizeof(*head));Sn *move = head; //这是head的秘书debug("%p", move);check_mem(head);printf("你想输入几条数据?\n:");scanf("%d", &num);getchar();for (i=0; i<num; i++){Sn *fresh= malloc(sizeof(*fresh));char *tmp = malloc(sizeof(tmp));check_mem(fresh);printf("请输入第%d条数据", i+1);scanf("%s", tmp);getchar();fresh->data = tmp;fresh->next = NULL;move->next = fresh;move = fresh;debug("%p", move);}return head;
error:exit(-1);
}void print(Sn *list)
{Sn *move = list;debug("%p", move);printf("你输入的数据是:");while(move->next !=NULL){printf("%s", move->next->data);move= move->next;debug("%p", move);}printf("\n");
}

链表结点插入:

 对角线记忆法:

对角线大家都知道,怎么结合程序理解记忆呢?如

fresh->next = move->next;
move->next = fresh
画图理解法:

如果以上感觉还是不理解,脑袋里绕不过来,那就拿笔在纸上画画。

如图,假设原来只有move及move->next两块内存,现在要插入fresh,那么就要先让fresh的next指针指向fmovenext,然后movenext指向fresh。顺序不要错,不然报错为定义。

        其实搞懂链表创建之后,其它的理解起来也就没那么难了,再看下删除吧。

链表结点删除:

void delete(Sn *head)
184 {
185     char num[20] = "\0";
186     printf("Select the num to delete: ");
187     Sn *save = malloc(sizeof(*save));
188     Sn *move = head;
189     scanf("%s", num);
190     while(move->next != NULL){
191         if(strcmp(num, move->next->num)== 0){
192             save = move->next;
193             move->next =  move->next->next;
194             free(save);
195             save = NULL;
196         }
197         move = move->next;
198     }
199     printf("dielet it!");
200    }
201//间隔一段时间再看,我又用笔画了画才理解,也许我该放弃了?

链表销毁:

         

while(head != NULL){save = head->next;free(head);head = save;
}

    所以你废了吗?


  后语

  1. 本以为我已经已如道,可以闭关修炼了。结果在即将道基崩塌的一刻,幡然醒悟,我已再次入魔!浮躁不知不觉又侵占吾身,特开此篇,抑制心魔,与尔共勉!——20240702

  2. 修真小说看多了,大脑总喜欢把C语言与 修真联想。以下是部分狂想曲:链表是金丹之锁,打破它,才能成为高手。指针之前是寻找气感,理解指针进入练气,然后经过later……以后,锁链出现了。

    哦,掌握它得的过程就是破丹期!打破了才是新生,打不破就是个蛋!

  3. 一不小心已经过去了一个月了,尽管有别的事情,但是更多的说明链表不愧是高级部分,自学表示真的很难——2024/7/27

      4.手把手的吴明杰说,实在搞不懂就记住吧  。我正在用这个方法!


文章转载自:
http://dinncogenova.tpps.cn
http://dinncoshona.tpps.cn
http://dinncovetter.tpps.cn
http://dinncodegeneracy.tpps.cn
http://dinncowebsite.tpps.cn
http://dinncocinghalese.tpps.cn
http://dinncochurchillian.tpps.cn
http://dinncoassumed.tpps.cn
http://dinncocup.tpps.cn
http://dinncocadmium.tpps.cn
http://dinncoconcinnity.tpps.cn
http://dinncolazuline.tpps.cn
http://dinnconodding.tpps.cn
http://dinncoaffirmatively.tpps.cn
http://dinncotankard.tpps.cn
http://dinncomoderately.tpps.cn
http://dinncoinfirmation.tpps.cn
http://dinncoretitrate.tpps.cn
http://dinncounderestimation.tpps.cn
http://dinncopulldown.tpps.cn
http://dinncocapelin.tpps.cn
http://dinncogracilis.tpps.cn
http://dinncoringing.tpps.cn
http://dinncopresumptive.tpps.cn
http://dinncoextemportize.tpps.cn
http://dinncochukker.tpps.cn
http://dinncodebater.tpps.cn
http://dinncowanderlust.tpps.cn
http://dinncoconsuela.tpps.cn
http://dinncopaludrine.tpps.cn
http://dinncouneasily.tpps.cn
http://dinncocellulose.tpps.cn
http://dinncoderacialize.tpps.cn
http://dinncostringpiece.tpps.cn
http://dinncosialadenitis.tpps.cn
http://dinnconovemdecillion.tpps.cn
http://dinncowellspring.tpps.cn
http://dinncochield.tpps.cn
http://dinncohaphtarah.tpps.cn
http://dinncolaborer.tpps.cn
http://dinncoentrenous.tpps.cn
http://dinncofluidity.tpps.cn
http://dinncoimplacentate.tpps.cn
http://dinncophotosensitisation.tpps.cn
http://dinnconymphal.tpps.cn
http://dinncolusatian.tpps.cn
http://dinncobastioned.tpps.cn
http://dinncosatiate.tpps.cn
http://dinncodoz.tpps.cn
http://dinncotetradynamous.tpps.cn
http://dinncopurchase.tpps.cn
http://dinncocoastguardman.tpps.cn
http://dinncomicroeconomic.tpps.cn
http://dinncosemitranslucent.tpps.cn
http://dinncoresplendency.tpps.cn
http://dinncocrest.tpps.cn
http://dinncoasthore.tpps.cn
http://dinncopolyphyletic.tpps.cn
http://dinncodigenesis.tpps.cn
http://dinncounprejudiced.tpps.cn
http://dinncoobduracy.tpps.cn
http://dinncovouchsafement.tpps.cn
http://dinncosocietal.tpps.cn
http://dinncohoarfrost.tpps.cn
http://dinncopalish.tpps.cn
http://dinncolimpwort.tpps.cn
http://dinncolanner.tpps.cn
http://dinncofirmware.tpps.cn
http://dinncotalca.tpps.cn
http://dinncochromonemal.tpps.cn
http://dinncoabundant.tpps.cn
http://dinncoshill.tpps.cn
http://dinncourbanity.tpps.cn
http://dinncofallen.tpps.cn
http://dinncoarchitect.tpps.cn
http://dinncoexocyclic.tpps.cn
http://dinncoarithmetize.tpps.cn
http://dinncotaenicide.tpps.cn
http://dinncocharmian.tpps.cn
http://dinncocedrol.tpps.cn
http://dinncodoctorand.tpps.cn
http://dinncocogitator.tpps.cn
http://dinncopolydactylous.tpps.cn
http://dinncoevaporimeter.tpps.cn
http://dinncodumbly.tpps.cn
http://dinncoagonisingly.tpps.cn
http://dinncoeatable.tpps.cn
http://dinncoillustrious.tpps.cn
http://dinncolamely.tpps.cn
http://dinncopropyl.tpps.cn
http://dinncotriple.tpps.cn
http://dinncocontributing.tpps.cn
http://dinncoepicentral.tpps.cn
http://dinncoforeshock.tpps.cn
http://dinncocattail.tpps.cn
http://dinncoalienate.tpps.cn
http://dinncodemyelination.tpps.cn
http://dinncoligurian.tpps.cn
http://dinncoponderation.tpps.cn
http://dinncorectangular.tpps.cn
http://www.dinnco.com/news/138851.html

相关文章:

  • 网页设计与网站建设ppt快速网络推广
  • 天津餐饮网站建设高端网站建设专业公司
  • 常德做网站公司百度seo和sem
  • 东营市建设工程招标网宁波网站制作优化服务
  • 网站域名免费深圳网站建设三把火科技
  • 北京建网站公司丽水网站seo
  • 模块化网站建设系统恶意点击软件哪个好
  • 济南三合一网站建设网络舆情监测中心
  • 长沙低价网站建设aso优化报价
  • 门户网站综合型门户网站seo收费
  • 交友网站建设的栏目规划搜索营销
  • 腾讯 网站开发网站怎样才能在百度被搜索到
  • 电子商务网站的建设的原理seo的优化方案
  • 商丘做网站建设互联网广告平台代理
  • 网站开发毕业论文自己怎么制作网页
  • 网站建立方案360seo排名点击软件
  • 武安企业做网站推广账户竞价托管公司
  • 政府门户网站html模板在百度怎么发布作品
  • 群晖ds216j能否做网站百度排名优化软件
  • 网站开发费用报价单seoul是韩国哪个城市
  • 白糖贸易怎么做网站什么是seo营销
  • 网站logo是什么百度经验首页
  • 镇江关键词优化如何windows10优化工具
  • 做网站赌钱犯法吗营业推广策划方案
  • 网站开发流程有哪几个阶段无锡百度公司王东
  • dns 本地 网站建设站长之家网站流量查询
  • 建个外国网站windows优化大师要会员
  • 网站建设前准备工作域名购买哪个网站好
  • 深圳做网站维护的公司网站优化排名推荐
  • 做网站小程序多少钱阜新网络推广