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

网站建设适合什么单位seo搜索引擎优化介绍

网站建设适合什么单位,seo搜索引擎优化介绍,贵州网站开发制作公司,学做网站要学什么顺序表是线性表的一种。 线性表是n个具有相同特性的数据元素的有限序列。 逻辑上,它们是线性结构,是一条连续的直线;但是在物理上,它们通常以数组和链式结构存储。 常见的线性表有顺序表、栈、队列、字符串等。 顺序表是用一段…

顺序表是线性表的一种。

线性表是n个具有相同特性的数据元素的有限序列。

逻辑上,它们是线性结构,是一条连续的直线;但是在物理上,它们通常以数组和链式结构存储。

常见的线性表有顺序表、栈、队列、字符串等。

顺序表是用一段物理地址连续的存储单元依次存储数据元素的线性结构,一般情况下采用数组存储,在数组上完成数据的增删查改。

但是要注意,动态顺序表的物理地址不一定连续!它的物理地址是否连续困扰了我好长时间,直到读到了这篇文章:http://www.manongjc.com/detail/56-gahnkhbaweoyxwy.html

顺序表一般可以分为:

1. 静态顺序表:使用定长数组存储。

2. 动态顺序表:使用动态开辟的数组存储。

以下是swarthmore对动态顺序表的解释:

Dynamically allocated arrays are allocated on the heap at run time. The heap space can be assigned to global or local pointer variables that store the address of the allocated heap space (point to the first bucket). To dynamically allocate space, use calls to malloc passing in the total number of bytes to allocate (always use the sizeof to get the size of a specific type). A single call to malloc allocates a contiguous chunk of heap space of the passed size.

原文链接:

https://www.cs.swarthmore.edu/~newhall/unixhelp/C_arrays.html#:~:text=Dynamically%20allocated%20arrays%20are%20allocated,point%20to%20the%20first%20bucket).

动态顺序表的基本形态:

typedef struct SeqList
{SLDataType* a;int size;     // 有效数据个数int capacity; // 空间容量
}SL;

下面是动态顺序表的接口实现:

一、初始化

typedef int SLDataType;
#define INIT_CAPACITY 4
void SLInit(SL* ps)
{ps->a = (SLDataType*)malloc(sizeof(SLDataType)* INIT_CAPACITY);if (ps->a == NULL){perror("malloc fail");return;}ps->size = 0;ps->capacity = INIT_CAPACITY;
}

使用malloc函数,向系统申请一定数量的空间。

如果没有申请成功,则a为NULL。

如果申请成功了,那a就不是NULL了,size将会被初始化为0。

由于已经成功申请了sizeof(SLDataType)* INIT_CAPACITY个空间,那么capacity的值就为INIT_CAPACITY。

二、检查和扩容

void SLCheckCapacity(SL* ps)
{assert(ps);if (ps->size == ps->capacity){SLDataType* tmp = (SLDataType*)realloc(ps->a, sizeof(SLDataType) * ps->capacity * 2);if (tmp == NULL){perror("realloc fail");return;}ps->a = tmp;ps->capacity *= 2;}
}

当数据个数和空间容量相等时,进行扩容。

这时要用到realloc函数了,即从ps->a的位置开始,向后申请sizeof(SLDataType)*ps->capacity*2个空间。

对的,没错,在这里,申请的空间是原来空间的1倍。当然可以申请别的大小的空间。

然后让a指向新开辟的空间的地址,将它们连接起来。

容量大小也相对应地乘2。

三、插入元素

typedef int SLDataType;
#define INIT_CAPACITY 4
void SLInsert(SL* ps, int pos, SLDataType x)
{assert(ps);assert(pos >= 0 && pos <= ps->size);SLCheckCapacity(ps);int end = ps->size - 1;while (end >= pos){ps->a[end + 1] = ps->a[end];--end;}ps->a[pos] = x;ps->size++;
}

在插入元素之前,要用断言,看看要插入的位置有没有在有效数据个数之内。

如果等于size,就相当于尾插;如果等于0,就相当于头插。

所以,在这里>=0和<=size是有必要的。

然后,不断循环,将要插入的位置原来的元素以及它后边的元素向后移动,直至end=pos。

四、删除元素

typedef int SLDataType;
#define INIT_CAPACITY 4
void SLErase(SL* ps, int pos)
{assert(ps);assert(pos >= 0 && pos < ps->size);int begin = pos + 1;while (begin < ps->size){ps->a[begin - 1] = ps->a[begin];++begin;}ps->size--;
}

删除元素本质上是将要删除的元素,用循环从后向前覆盖, 最后size自减1。

五、头插

typedef int SLDataType;
#define INIT_CAPACITY 4
void SLPushFront(SL* ps, SLDataType x)
{SLInsert(ps, 0, x);
}

在插入元素的基础上实现头插。

六、头删

typedef int SLDataType;
#define INIT_CAPACITY 4
void SLPopFront(SL* ps)
{SLErase(ps, 0);
}

在删除元素的基础上实现头删。 

七、尾插

typedef int SLDataType;
#define INIT_CAPACITY 4
void SLPushBack(SL* ps, SLDataType x)
{SLInsert(ps, ps->size, x);
}

在插入元素的基础上实现尾插。 

八、尾删

typedef int SLDataType;
#define INIT_CAPACITY 4
void SLPopBack(SL* ps)
{SLErase(ps, ps->size-1);
}

在删除元素的基础上实现尾删。 

九、查找元素

int SLFind(SL* ps, SLDataType x)
{assert(ps);for(int i = 0; i < ps->size; ++i){if (ps->a[i] == x){return i;}}return -1;
}

即遍历数组,找到后返回数组下标。

十、打印数组

typedef int SLDataType;
#define INIT_CAPACITY 4
void SLPrint(SL* ps)
{assert(ps);for (int i = 0; i < ps->size; ++i){printf("%d ", ps->a[i]);}printf("\n");
}

遍历打印输出即可。

十一、销毁

typedef int SLDataType;
#define INIT_CAPACITY 4
void SLDestroy(SL* ps)
{assert(ps);free(ps->a);ps->a = NULL;ps->capacity = ps->size = 0;
}
http://www.dinnco.com/news/68048.html

相关文章:

  • 装修网站建设网页制作与网站建设实战教程
  • 全国住房和城乡建设部网站百度集团官网
  • 做app模板网站有哪些南京谷歌优化
  • 关于建设学校网站的报告书seo技术平台
  • 如何做外贸网站百度关键词排名推广
  • 百度上找不到网站优化大师的三大功能
  • 沈阳外贸网站建设网络建站平台
  • 有没有做吉祥物的网站网络公司推广公司
  • app网站公司网络维护
  • 上海百度做网站sem是什么的英文缩写
  • 做网站项目如何实现支付国内快速建站
  • 做护肤品好的网站好郑州网站制作推广公司
  • 做网站创业故事外链代发免费
  • 手机互动网站建设友情链接购买平台
  • 哪些人做数据监测网站星乐seo网站关键词排名优化
  • 女同性怎么做的视频网站网络营销的推广方式
  • 做网站是java还是php百度搜索引擎工作原理
  • wordpress整站导入百度高级搜索功能
  • java做网站开发网站分析案例
  • 做废品回收哪个网站好点移动营销
  • wordpress 万网seo外链是什么
  • 怎么用电脑给域名做网站博客程序seo
  • 抚顺市网站建设网站优化
  • 济源建设工程管理处网站国外比较开放的社交软件
  • 红木家具网站模板可以发外链的网站整理
  • wordpress网站欣赏怎么建立一个网站
  • 利用小程序反向做网站企业管理
  • 关于网站建设的标语青岛网站建设方案服务
  • 数字网站建设cps广告联盟网站
  • 现代示范校建设专题网站浏览器下载安装