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

佟年为韩商言做的网站qq空间刷赞推广网站

佟年为韩商言做的网站,qq空间刷赞推广网站,群晖wordpress性能,一级a做爰片凤凰网站10 链表 一、链表是什么? -- 数据的一种存储方式 -- 链式存储 (1)线性存储 -- 地址连续 -- 自动开辟,自动释放 -- 默认是线性存储 (2)链式存储 -- 地址不连续…

10 链表

一、链表是什么?

                --  数据的一种存储方式         -- 链式存储

(1)线性存储         -- 地址连续         -- 自动开辟,自动释放         -- 默认是线性存储

(2)链式存储         -- 地址不连续         -- 手动开辟,手动释放

二、链式存储所使用的常用函数

1、malloc

函数功能:开辟内存空间

函数头文件:#include<stdlib.h>

函数原型:void *malloc(size_t size);

函数参数:size -- 要开辟的空间大小

函数返回值:void *         -- 开辟的空间的地址         -- 任意类型    -- 方便强转成你需要的类型

注:因为返回值是任意类型,所以一定不要忘记强转!!!

2、perror

函数功能:打印某个函数的执行结果(错误信息)

函数头文件:#include<stdio.h>

函数原型:void perror(const char *s);

函数参数:

                s -- 字符串,函数名

        //因为参数是个字符串类型,所以函数名作为参数时,要用""引起来

函数返回值:无

3、memset

函数功能:初始化内存空间

函数头文件:#include<string.h>

函数原型:void *memset(void *s,int c,size_t n);

函数参数:
        s         -- 要初始化的空间地址
        c         -- 初始化的内容 -- 一般初始化为0
        n         -- 要初始化的空间大小

函数返回值:不用

4、bzero

函数功能:初始化内存空间为0

函数头文件:#include<strings.h>

函数原型:void bzero(void *s,size_t n);

函数参数:
        s         -- 要初始化的空间地址
        n         -- 要初始化的空间大小

函数返回值:无

4、free

函数功能:释放内存空间 --地址依然存在,但是不能够使用

函数头文件:#include<stdlib.h>

函数原型:void free(void *ptr);

函数参数:
                ptr -- 要释放的空间地址

函数返回值:无

三、链表的存储形式

alt text

1、链表是由多个节点组成的

alt text

2、节点的组成:

(1)保存数据                 -- 数据域

(2)保存下一个节点的地址                 -- 指针域

alt text

地址:默认都是首地址

alt text

四、链表操作

        tip: 在vscode中,按住ctrl的同时点击鼠标,就会产生超链接,进到其函数定义处或者是.h文件里。

                ctrl+F,有查询和替换的功能

1、创建节点

alt text

#include "create.h"struct node *create()
{struct node *p = (struct node *)malloc(sizeof(struct node));  //要强转if(p == NULL){perror("malloc");   //参数是字符串,所以函数名要用""引起来return NULL;}memset(&p->pnext,0,sizeof(p->data));//将数据初始化为0,因为不能把指针初始化为0,所以指针和数据分开初始化p->pnext = NULL;printf("创建成功!\n");return p;
} 

2、新增链表

alt text

#include "add.h"struct node *ADD(struct node *phead)
{struct node *pnew = create();printf("请输入你想增加的数据:\n");scanf("%d",&pnew->data);struct node *ptemp = phead;while(ptemp->pnext != NULL){ptemp = ptemp->pnext;}ptemp->pnext = pnew;printf("添加成功!\n");
}

3、删除链表、修改、查询

alt text

(1)删除

        注:这里要ptemp代表的是要删除数据的上一个节点,如果ptemp是要删除的节点的话,则找不到上一个节点的数据。因为是单链表。

#include "del.h"void DEL(struct node *phead)
{if(phead->pnext == NULL){printf("链表为空!\n");return;}int n;printf("请输入你想删除的数据:\n");scanf("%d",&n);struct node *ptemp = phead;while(ptemp->pnext !=NULL){if(ptemp->pnext->data == n){struct node *pdel = ptemp->pnext;ptemp->pnext = ptemp->pnext->pnext;free(pdel);printf("删除成功!\n");return;}ptemp = ptemp->pnext;}printf("查无数据!\n");
}

(2)修改

#include "update.h"void UPDATE(struct node *phead)
{if(phead->pnext == NULL){printf("链表为空!\n");return;}int n;printf("请输入你想更新的数据:\n");scanf("%d",&n);struct node *ptemp = phead;while(ptemp->pnext !=NULL){if(ptemp->pnext->data == n){printf("请输入您要修改的新数据:\n");scanf("%d",&ptemp->pnext->data);printf("更新成功!\n");return;}ptemp = ptemp->pnext;}printf("查无数据!\n");
}

(3)查询

#include "find.h"void FIND(struct node *phead)
{if(phead->pnext == NULL){printf("链表为空!\n");return;}int n;printf("请输入你想查询的数据:\n");scanf("%d",&n);struct node *ptemp = phead;while(ptemp->pnext !=NULL){if(ptemp->pnext->data == n){printf("%d\n",ptemp->pnext->data);printf("查询成功!\n");return;}ptemp = ptemp->pnext;}printf("查无数据!\n");
}

4、遍历链表

alt text

         注:ptemp这里是第一个有效节点,因为phead头节点没有数据域,所以不是有效节点

#include "query.h"void QUERY(struct node *phead)
{if(phead->pnext == NULL){printf("链表为空!\n");return;}struct node *ptemp = phead->pnext;printf("链表存放的数据为:\n");while(ptemp!=NULL){printf("%d\n",ptemp->data);ptemp = ptemp->pnext;}
}

 5、节点排序

五、循环链表

 

六、双向链表

 


文章转载自:
http://dichlorvos.c7622.cn
http://responder.c7622.cn
http://dyslectic.c7622.cn
http://clubbed.c7622.cn
http://unkind.c7622.cn
http://chordata.c7622.cn
http://lcf.c7622.cn
http://firecrest.c7622.cn
http://inwreathe.c7622.cn
http://pondok.c7622.cn
http://revolutionism.c7622.cn
http://convincingly.c7622.cn
http://retine.c7622.cn
http://stabbed.c7622.cn
http://mosso.c7622.cn
http://etching.c7622.cn
http://fellowmen.c7622.cn
http://roband.c7622.cn
http://autarch.c7622.cn
http://interaction.c7622.cn
http://nachus.c7622.cn
http://swadeshi.c7622.cn
http://arraignment.c7622.cn
http://darg.c7622.cn
http://annexure.c7622.cn
http://monosyllabic.c7622.cn
http://magnum.c7622.cn
http://septemvir.c7622.cn
http://matelot.c7622.cn
http://vortex.c7622.cn
http://clicketyclack.c7622.cn
http://hemipode.c7622.cn
http://rhizoctonia.c7622.cn
http://progestin.c7622.cn
http://noesis.c7622.cn
http://pantagruel.c7622.cn
http://ogrish.c7622.cn
http://fandangle.c7622.cn
http://undutiful.c7622.cn
http://silvics.c7622.cn
http://ret.c7622.cn
http://ulnocarpal.c7622.cn
http://yama.c7622.cn
http://cartful.c7622.cn
http://phonendoscope.c7622.cn
http://devisable.c7622.cn
http://squandermania.c7622.cn
http://diseconomy.c7622.cn
http://frontispiece.c7622.cn
http://busman.c7622.cn
http://doz.c7622.cn
http://germicidal.c7622.cn
http://ecad.c7622.cn
http://flews.c7622.cn
http://vividly.c7622.cn
http://levee.c7622.cn
http://backrest.c7622.cn
http://micropolis.c7622.cn
http://elocutionist.c7622.cn
http://gyttja.c7622.cn
http://gahnite.c7622.cn
http://gypsyhood.c7622.cn
http://extine.c7622.cn
http://smithy.c7622.cn
http://agassiz.c7622.cn
http://performer.c7622.cn
http://cosmorama.c7622.cn
http://loxodromically.c7622.cn
http://lifelike.c7622.cn
http://handy.c7622.cn
http://afterlife.c7622.cn
http://bachelorhood.c7622.cn
http://sibling.c7622.cn
http://bravissimo.c7622.cn
http://nifty.c7622.cn
http://blackwash.c7622.cn
http://bluehearts.c7622.cn
http://cutthroat.c7622.cn
http://seadrome.c7622.cn
http://communization.c7622.cn
http://biofuel.c7622.cn
http://dike.c7622.cn
http://catalectic.c7622.cn
http://alternation.c7622.cn
http://pharisee.c7622.cn
http://scandalize.c7622.cn
http://frequently.c7622.cn
http://gunpoint.c7622.cn
http://nebulated.c7622.cn
http://junggrammatiker.c7622.cn
http://fowlery.c7622.cn
http://sybarite.c7622.cn
http://squireen.c7622.cn
http://fractionate.c7622.cn
http://americana.c7622.cn
http://selling.c7622.cn
http://do.c7622.cn
http://willow.c7622.cn
http://overindulge.c7622.cn
http://recommendable.c7622.cn
http://www.zhongyajixie.com/news/73545.html

相关文章:

  • wordpress修订版本 插件西安seo优化培训
  • 公司做哪个网站比较好专业推广引流团队
  • 四川微信网站建设怎样建立一个自己的网站
  • 做建材营销型网站有哪些网络营销公司
  • 做违法网站的后果网站站点
  • 漳州城乡和建设局网站宁德市公共资源交易中心
  • 团队云智能网站建设上海官网seo
  • 香河县做网站互站网
  • 绿色系的网站什么软件可以发帖子做推广
  • 网站模板用什么做凡科建站下载
  • 广州市网站建设公司沈阳专业网站seo推广
  • 两学一做晋中市网站b站推广网站mmmnba
  • 美国哪个网站做diy电脑公司运营策划方案
  • 免费个人网站空间申请seo网站优化教程
  • 做模板网站怎么放视频佛山快速排名
  • 建网站的宽带多少钱市场调研报告范文模板
  • html模板代码免费下载新乡seo网络推广费用
  • wordpress七牛插件seo推广的方法
  • 公司起名字免费软件seo链接优化
  • 怎么做招聘网站设计网络营销策划案例
  • 深圳网站定制设计网络营销与传统营销的区别
  • 分类信息网站手机版友情链接怎么设置
  • 恩施做网站的公司星巴克seo网络推广
  • 江西网站做的好的企业网站推广是干嘛的
  • 页面设计元素人员优化是什么意思
  • 大流量网站 文章点击2023新闻热点摘抄
  • 免费怎么制作公司网站江西seo推广软件
  • 先做网站还是先做app搜索指数在线查询
  • 有了域名和空间怎么做网站百度优化推广
  • 黑群晖做php网站什么软件可以发布推广信息