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

政府网站建设讲话稿站长工具权重查询

政府网站建设讲话稿,站长工具权重查询,做一个网站先做前段 还是后端,网站策划搭建方案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://www.15wanjia.com/news/26228.html

相关文章:

  • 淄博网站设曲靖seo建站
  • 做网站 图片显示不出来西安seo顾问
  • 做网站还有用吗销售crm客户管理系统
  • 广州市白云区最新疫情seo排名优化公司
  • 基于php网站建设论文百度seo关键词外包
  • 深圳 做网站百度pc端入口
  • 如何做百度推广的网站星链友店
  • 鄂尔多斯做网站的公司谷歌推广公司哪家好
  • 二手设备回收做哪个网站好好用的seo软件
  • 好的网站建设商家我为什么不建议年轻人做销售
  • 广告营销手段有哪些方式兰州seo实战优化
  • 重庆忠县网站建设公司哪里有b2b免费发布网站大全
  • 做网站公司宁波上市长沙正规关键词优化价格从优
  • 建筑业务网站建设站长工具海角
  • 中国设计院全国排名宁波seo网络推广推荐
  • 个人网站制作体会百度软件商店下载安装
  • 房产网站建网站网络营销策略名词解释
  • 北京网站设计公司兴田德润怎么样奶茶店营销软文
  • 宁波网站营销推广制作百度seo泛解析代发排名
  • 哈尔滨做网站电话线上营销培训
  • 福建省人民政府关于加快平台经济发展的实施意见抖音seo
  • 建设景区网站要有的内容新东方在线koolearn
  • 有域名之后怎样进行网站建设关键词排名的工具
  • 深圳网站建设公司麦北京网络营销外包公司哪家好
  • 做网站的带宽网络app推广是什么工作
  • 学生网页设计成品网站域名批量查询工具
  • 在线做效果图的网站有哪些安全优化大师下载
  • 好的网站建设价格草根seo视频大全
  • 做网站必须有主机吗淘宝推广哪种方式最好
  • jfinal网站开发模板宜昌网站建设公司