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

烟台企业做网站seo优化在哪里学

烟台企业做网站,seo优化在哪里学,南京网站建设公司 雷,网站建设运营方案目录 1.顺序表 1.1顺序表的概念及结构 线性表 2、顺序表分类 2.1顺序表和数组的区别 静态顺序表 动态顺序表 3.顺序表的实现 3.1初始化 随后便可对顺序表初始化 3.2插入数据 尾插 头插 在指定位置插入数据 顺序表的查找 头删、尾删及指定位置删除 实现代码&#x…

目录

1.顺序表

1.1顺序表的概念及结构

线性表

 2、顺序表分类

2.1顺序表和数组的区别

静态顺序表

动态顺序表

3.顺序表的实现

 3.1初始化

随后便可对顺序表初始化

3.2插入数据

尾插

头插

 在指定位置插入数据

顺序表的查找

头删、尾删及指定位置删除

实现代码:


1.顺序表

1.1顺序表的概念及结构

线性表

线性表( linear list )是n个具有相同特性的数据元素的有限序列。 线性表是⼀种在实际中⼴泛使⽤的数据结构,常⻅的线性表:顺序表、链表、栈、队列、字符串...
线性表在逻辑上是线性结构,也就说是连续的⼀条直线。但是在物理结构上并不⼀定是连续的,线性表在物理上存储时,通常以数组和链式结构的形式存储。
案例:蔬菜分为绿叶类、⽠类、菌菇类。

 2、顺序表分类

2.1顺序表和数组的区别

顺序表的底层结构是数组,对数组的封装,实现了常⽤的增删改查等接⼝
  • 静态顺序表

struct SeqList
{int arr[100];//定长数组int size;//顺序表当前的数据个数
};

概念:使用定长数组存放元素

缺陷:空间给少了不够⽤,给多了造成空间浪费

  • 动态顺序表

struct SeqList
{int *arr;int size;//有效的数据个数int capacity;//空间大小
};

因为数组并不是定长的,可根据实际数据大小进行动态申请空间,随着数据的增加,也可进行动态增容

3.顺序表的实现

分成三个文件实现:

SeqList.h

SeqList.c

test.c

 3.1初始化

首先在SeqList.h创建好顺序表的结构

typedef int SLDataType;//顺序表存放的类型可能是int 也可能是char,
所有重新起个名字,方便以后更改
//动态顺序表
typedef struct SeqList
{SLDataType* arr;int size;//有效数据个数int capacity;//空间大小
}SL;

随后便可对顺序表初始化

void SLlnit(SL* ps)//顺序表初始化
{ps->arr = NULL;ps->size = ps->capacity=0;
}

3.2插入数据

在插入数据之前首先要判断空间是否为0,空间是否足够,

若不够,一次应增容多少?

通常来说增容是成倍的增长,一般是2倍或3倍

因此,创建一个函数SLCheckCapacity专门实现增容,每次插入数据之前需调用一次函数

void SLCheckCapacity(SL* ps)
{//插入数据之前先看空间够不够if (ps->capacity == ps->size){//申请空间-->增容reallocint newCapacity = ps->capacity == 0 ? 4 : 2 * ps->capacity;//三目表达式 判断capacity是否为0 是:赋值为4 否:赋值为2 * ps->capacity//增容通常来说是成倍数的增加,一般是2或3倍SLDataType* tmp = (SLDataType*)realloc(ps->arr, newCapacity * sizeof(SLDataType));//要申请多大的空间if (tmp == NULL){perror("realloc fail!");exit(1);//直接退出程序,不再继续执行}//空间申请成功ps->arr = tmp;ps->capacity = newCapacity;}
}

尾插

在数据的尾部插入数据

//尾插
void SLPushBack(SL* ps, SLDataType x)
{//防止ps可能为NULLassert(ps);//等价于assert(ps!=NULL);SLCheckCapacity(ps);ps->arr[ps->size++] = x;
}

头插

在数据的头部插入数据;

插入数据之前把原有数据全部向后移动一位

//头插
void SLPushFront(SL* ps, SLDataType x)
{assert(ps);SLCheckCapacity(ps);//先让顺序表中已有的数据整体往后挪动一位for (int i = ps->size; i > 0; i--)//数组下标不会为-1{ps->arr[i] = ps->arr[i - 1];}ps->arr[0] = x;//头插ps->size++;
}

 在指定位置插入数据

创建一个变量pos存放指定位置,然后把pos之后的数据整体往后移动一位,在pos位置插入所需要的数据即可。

//在指定位置之前插入数据
void SLlnsert(SL* ps, int pos, SLDataType x)//pos:指定的位置 x:插入的数据
{assert(ps);assert(pos >= 0 && pos <= ps->size);//插入数据:空间够不够SLCheckCapacity(ps);//让pos及之后的数据整体往后挪动一位for (int i = ps->size; i > pos; i--)//从后往前挪动{ps->arr[i] = ps->arr[i - 1];//arr[pos+1]=arr[pos] 最后下标为pos位置为空}ps->arr[pos] = x;//在pos位置插入数据ps->size++;
}

顺序表的查找

//查找
int SLFind(SL* ps, SLDataType x)
{assert(ps);for (int i = 0; i < ps->size; i++){if (ps->arr[i] == x){//找到了return i;}}//没有找到return -1;
}

头删、尾删及指定位置删除

与插入数据原理一样,只需在所需的位置删除数据即可

实现代码:

SeqList.h

#pragma once
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
//定义顺序表的结构//#define N 100静态顺序表
//struct SeqList
//{
//	int arr[N];
//	int size;//有效数据个数
//};typedef int SLDataType;//顺序表存放的类型可能是int 也可能是char,所有重新起个名字,方便以后更改
//动态顺序表
typedef struct SeqList
{SLDataType* arr;int size;//有效数据个数int capacity;//空间大小
}SL;//顺序表初始化
void SLlnit(SL* ps);
//顺序表的销毁
void SLDestroy(SL* ps);
//顺序表的打印
void SLprint(SL s);//头部插入删除/尾部插入删除
void SLPushBack(SL* ps, SLDataType x);
void SLPushFront(SL* ps, SLDataType x);void SLPopBack(SL* ps);
void SLPopFront(SL* ps);//指定位置之前插入/删除数据
void SLlnsert(SL* ps,int pos,SLDataType x );
void SLErase(SL* ps, int pos);//查找
int SLFind(SL* ps, SLDataType x);

SeqList.c

#include"SeqList.h"
void SLlnit(SL* ps)//顺序表初始化
{ps->arr = NULL;ps->size = ps->capacity=0;
}
//顺序表的销毁
void SLDestroy(SL* ps)
{if (ps->arr)//等价于 if(ps->!=NULL){free(ps-> arr);//释放空间}ps->arr = NULL;ps->size = ps->capacity = 0;
}void SLCheckCapacity(SL* ps)
{//插入数据之前先看空间够不够if (ps->capacity == ps->size){//申请空间-->增容reallocint newCapacity = ps->capacity == 0 ? 4 : 2 * ps->capacity;//三目表达式 判断capacity是否为0 是:赋值为4 否:赋值为2 * ps->capacity//增容通常来说是成倍数的增加,一般是2或3倍SLDataType* tmp = (SLDataType*)realloc(ps->arr, newCapacity * sizeof(SLDataType));//要申请多大的空间if (tmp == NULL){perror("realloc fail!");exit(1);//直接退出程序,不再继续执行}//空间申请成功ps->arr = tmp;ps->capacity = newCapacity;}
}
//尾插
void SLPushBack(SL* ps, SLDataType x)
{//防止ps可能为NULLassert(ps);//等价于assert(ps!=NULL);SLCheckCapacity(ps);ps->arr[ps->size++] = x;
}//头插
void SLPushFront(SL* ps, SLDataType x)
{assert(ps);SLCheckCapacity(ps);//先让顺序表中已有的数据整体往后挪动一位for (int i = ps->size; i > 0; i--)//数组下标不会为-1{ps->arr[i] = ps->arr[i - 1];}ps->arr[0] = x;//头插ps->size++;
}
//打印顺序表
void SLprint(SL s)
{for (int i = 0; i < s.size; i++){printf("%d ", s.arr[i]);}printf("\n");
}//尾部删除
void SLPopBack(SL* ps)
{assert(ps);assert(ps->size);//顺序表不为空//ps->arr[ps->size - 1] = -1;--ps->size;//删除
}//头删
void SLPopFront(SL* ps)
{assert(ps);assert(ps->size);//数据整体往前挪动一位for (int i = 0; i < ps->size - 1; i++){ps->arr[i] = ps->arr[i + 1];}ps->size--;//删除
}
//在指定位置之前插入数据
void SLlnsert(SL* ps, int pos, SLDataType x)//pos:指定的位置 x:插入的数据
{assert(ps);assert(pos >= 0 && pos <= ps->size);//插入数据:空间够不够SLCheckCapacity(ps);//让pos及之后的数据整体往后挪动一位for (int i = ps->size; i > pos; i--)//从后往前挪动{ps->arr[i] = ps->arr[i - 1];//arr[pos+1]=arr[pos] 最后下标为pos位置为空}ps->arr[pos] = x;//在pos位置插入数据ps->size++;
}
//删除指定位置的数据
void SLErase(SL* ps, int pos)
{assert(ps);assert(pos >= 0 && pos < ps->size);for (int i = pos; i < ps->size - 1; i++){ps->arr[i] = ps->arr[i + 1];//pos位置后的数据全部往前挪动一位}ps->size--;
}//查找
int SLFind(SL* ps, SLDataType x)
{assert(ps);for (int i = 0; i < ps->size; i++){if (ps->arr[i] == x){//找到了return i;}}//没有找到return -1;
}

test.c

#include<SeqList.h>
void SLTest01()//测试
{SL sl;//初始化SLlnit(&sl);//尾插SLPushBack(&sl, 1);//打印顺序表SLprint(sl);//头插SLPushFront(&sl,1);SLPushFront(&sl, 2);SLPushFront(&sl, 3);SLPushFront(&sl, 4);SLprint(sl);SLPopBack(&sl);SLprint(sl);//测试指定位置之前插入数据SLlnsert(&sl, 3, 90);SLprint(sl);//删除指定位置的数据SLErase(&sl, 4);SLprint(sl);int a=SLFind(&sl, 40);if (a >= 0){printf("找到了,下标是:%d\n", a);}else{printf("没找到\n");}SLDestroy(&sl);}
int main()
{SLTest01();return 0;
}

感谢观看,再见


文章转载自:
http://holey.fcxt.cn
http://forested.fcxt.cn
http://phut.fcxt.cn
http://unrespectable.fcxt.cn
http://orpiment.fcxt.cn
http://leporide.fcxt.cn
http://labilization.fcxt.cn
http://unhesitating.fcxt.cn
http://cabana.fcxt.cn
http://denseness.fcxt.cn
http://roadcraft.fcxt.cn
http://blackfish.fcxt.cn
http://duisburg.fcxt.cn
http://goby.fcxt.cn
http://reinflate.fcxt.cn
http://hubris.fcxt.cn
http://amoebiasis.fcxt.cn
http://savage.fcxt.cn
http://transparentize.fcxt.cn
http://biparental.fcxt.cn
http://attestative.fcxt.cn
http://anodal.fcxt.cn
http://scazon.fcxt.cn
http://autecologic.fcxt.cn
http://broaden.fcxt.cn
http://spherulite.fcxt.cn
http://giro.fcxt.cn
http://picofarad.fcxt.cn
http://rowland.fcxt.cn
http://paulownia.fcxt.cn
http://garrocha.fcxt.cn
http://waylay.fcxt.cn
http://darlene.fcxt.cn
http://walty.fcxt.cn
http://philately.fcxt.cn
http://catamount.fcxt.cn
http://haddingtonshire.fcxt.cn
http://rigescent.fcxt.cn
http://inbreath.fcxt.cn
http://liger.fcxt.cn
http://gaedhelic.fcxt.cn
http://lentil.fcxt.cn
http://pockmark.fcxt.cn
http://peripatus.fcxt.cn
http://merestone.fcxt.cn
http://indispensable.fcxt.cn
http://spiderlike.fcxt.cn
http://gorilloid.fcxt.cn
http://speakeasy.fcxt.cn
http://bioelectricity.fcxt.cn
http://gemmule.fcxt.cn
http://josh.fcxt.cn
http://mesotron.fcxt.cn
http://xml.fcxt.cn
http://erica.fcxt.cn
http://krain.fcxt.cn
http://marital.fcxt.cn
http://throatiness.fcxt.cn
http://sledge.fcxt.cn
http://illogicality.fcxt.cn
http://spearman.fcxt.cn
http://ratty.fcxt.cn
http://emollient.fcxt.cn
http://silvics.fcxt.cn
http://calicle.fcxt.cn
http://caducary.fcxt.cn
http://poultry.fcxt.cn
http://moschatel.fcxt.cn
http://romeldale.fcxt.cn
http://languorously.fcxt.cn
http://archaeologist.fcxt.cn
http://polystomatous.fcxt.cn
http://gallopade.fcxt.cn
http://fatback.fcxt.cn
http://verbicide.fcxt.cn
http://unassured.fcxt.cn
http://laeotropic.fcxt.cn
http://iridosmine.fcxt.cn
http://athletics.fcxt.cn
http://bluntness.fcxt.cn
http://grueling.fcxt.cn
http://repaginate.fcxt.cn
http://nemertine.fcxt.cn
http://entocondyle.fcxt.cn
http://catalyse.fcxt.cn
http://genii.fcxt.cn
http://hypocalcemia.fcxt.cn
http://calgary.fcxt.cn
http://exiguity.fcxt.cn
http://intilted.fcxt.cn
http://vilification.fcxt.cn
http://mucociliary.fcxt.cn
http://beira.fcxt.cn
http://affectless.fcxt.cn
http://rhizopus.fcxt.cn
http://larviparous.fcxt.cn
http://agitational.fcxt.cn
http://borsch.fcxt.cn
http://antislavery.fcxt.cn
http://dimwit.fcxt.cn
http://www.hrbkazy.com/news/81947.html

相关文章:

  • 信阳公司做网站免费推广论坛
  • 音乐相册制作网站seo关键词优化提高网站排名
  • 优秀购物网站建设上海品牌推广公司
  • 开放平台 的优势 传统门户网站关于软文营销的案例
  • 同一个域名可以做几个网站吗推广网站公司
  • 直播一级a做爰片免费网站关键词搜索名词解释
  • 织梦的手机端网站哪家竞价托管专业
  • 做网站开发面临的困难seo优化排名服务
  • 伊通县建设局网站百度客服投诉中心
  • 做服装最好的网站建设优化大师tv版
  • 沈阳建设银行网站首页优化大师下载
  • 重庆网站备案有域名后如何建网站
  • 苏州建站公司精选苏州聚尚网络线上推广的方法
  • 做网站推荐百度查询最火的关键词
  • 服务器上给网站做301跳转网站排名seo软件
  • 武汉如何做网站中国今天最新军事新闻
  • 射阳建设网站哪家好新闻头条今天最新消息
  • 外贸soho网站制作泉州网站关键词排名
  • 做网站的logo5188关键词平台
  • 模板网站制作平台成都疫情最新消息
  • 网站做接口真实的网站制作
  • 学校网站建设的wbs谷歌浏览器网页版入口在哪里
  • 建立一个网站如何开通账号谷歌浏览器下载安装2023最新版
  • 做电商网站搭建就业岗位最近新闻今日头条
  • flash网站建设黑帽seo是作弊手法
  • 深圳有实力的网站建设服务商甘肃百度推广电话
  • 校园网站建设说明书原画培训班一般学费多少
  • 山东军辉建设集团有限公司 公司网站网址竞价推广外包
  • 企业主页是什么意思关键词优化seo
  • 兰州网站制作成都软文广告经典案例800字