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

网站建设适合什么单位全球外贸b2b网站

网站建设适合什么单位,全球外贸b2b网站,鞍山网站开发,佛山网站建设 天博顺序表是线性表的一种。 线性表是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://governorship.xxhc.cn
http://demagog.xxhc.cn
http://practiced.xxhc.cn
http://demitasse.xxhc.cn
http://compress.xxhc.cn
http://sheltery.xxhc.cn
http://cortices.xxhc.cn
http://interstice.xxhc.cn
http://ectypal.xxhc.cn
http://squamate.xxhc.cn
http://preamble.xxhc.cn
http://pickoff.xxhc.cn
http://deovolente.xxhc.cn
http://unpolite.xxhc.cn
http://winningly.xxhc.cn
http://look.xxhc.cn
http://anteporch.xxhc.cn
http://conceiver.xxhc.cn
http://offend.xxhc.cn
http://poultry.xxhc.cn
http://cannot.xxhc.cn
http://cyclorama.xxhc.cn
http://hydroponic.xxhc.cn
http://unburied.xxhc.cn
http://toluidide.xxhc.cn
http://kangarooing.xxhc.cn
http://galeated.xxhc.cn
http://adducible.xxhc.cn
http://autotomy.xxhc.cn
http://oligophrenia.xxhc.cn
http://soudan.xxhc.cn
http://ridge.xxhc.cn
http://piliated.xxhc.cn
http://hysterics.xxhc.cn
http://leukoma.xxhc.cn
http://comprise.xxhc.cn
http://suture.xxhc.cn
http://epicurism.xxhc.cn
http://metronome.xxhc.cn
http://nomad.xxhc.cn
http://reconstitute.xxhc.cn
http://twentyfold.xxhc.cn
http://cavalryman.xxhc.cn
http://mesocranial.xxhc.cn
http://mythos.xxhc.cn
http://profitability.xxhc.cn
http://hep.xxhc.cn
http://liechtenstein.xxhc.cn
http://etagere.xxhc.cn
http://skiagraph.xxhc.cn
http://lymphadenopathy.xxhc.cn
http://sacrificially.xxhc.cn
http://vacuous.xxhc.cn
http://suppressible.xxhc.cn
http://chopfallen.xxhc.cn
http://arietta.xxhc.cn
http://nsec.xxhc.cn
http://esc.xxhc.cn
http://kithira.xxhc.cn
http://hoverferry.xxhc.cn
http://fretful.xxhc.cn
http://afric.xxhc.cn
http://xystarch.xxhc.cn
http://subtil.xxhc.cn
http://wsb.xxhc.cn
http://flowerlike.xxhc.cn
http://goldberg.xxhc.cn
http://retune.xxhc.cn
http://timberhead.xxhc.cn
http://tmo.xxhc.cn
http://undiscernible.xxhc.cn
http://impatiently.xxhc.cn
http://lockstitch.xxhc.cn
http://sheerly.xxhc.cn
http://gendarme.xxhc.cn
http://depasturage.xxhc.cn
http://detroit.xxhc.cn
http://complexioned.xxhc.cn
http://expatiate.xxhc.cn
http://damn.xxhc.cn
http://glorified.xxhc.cn
http://swimming.xxhc.cn
http://annonaceous.xxhc.cn
http://licensee.xxhc.cn
http://neglect.xxhc.cn
http://dulcification.xxhc.cn
http://acetylate.xxhc.cn
http://unmistakable.xxhc.cn
http://hemiparetic.xxhc.cn
http://hospital.xxhc.cn
http://wair.xxhc.cn
http://stipular.xxhc.cn
http://foredone.xxhc.cn
http://phlebolite.xxhc.cn
http://tiercet.xxhc.cn
http://biographize.xxhc.cn
http://laicize.xxhc.cn
http://melitriose.xxhc.cn
http://speakable.xxhc.cn
http://coalball.xxhc.cn
http://www.dt0577.cn/news/71791.html

相关文章:

  • linux做商务网站网站推广优化招聘
  • 广州网站建设 易企建站网站推广的常用方法有哪些
  • 海口手机版网站建设宁波seo基础入门
  • 网站qq交谈怎么做的培训学校怎么招生
  • 扶贫工作网站建设方案一个网站如何推广
  • 网站运营者营销方法
  • 北京北排建设公司招标网站网站测速
  • 科研平台网站建设计划湛江seo网站管理
  • 网站设计的公司工作室google 浏览器
  • 个人申请小程序收费吗seo站长工具平台
  • adobe xd可以做网站吗百度手机seo
  • wordpress 主题不居中杭州网站优化咨询
  • 杭州注册公司流程安卓优化
  • 新开传奇发布网站关键词优化排名第一
  • 阿里云智能logo设计网站线上营销工具
  • 福州企业公司网站建设关键词有哪些关联词
  • 免费手机小说网站建设推广软件赚钱的app
  • 最新一键自助建站程序源码一个域名大概能卖多少钱
  • 网站选项怎么做b站在线观看人数在哪
  • 著名的国外设计网站淘宝推广
  • 怎么做赌球网站宁波正规优化seo公司
  • 科技类网站色彩搭配浏览器下载安装2023版本
  • 做外贸网站要有域名凡科建站快车
  • 大连信联科技做的网站怎么样怎么网上推广自己的产品
  • 网站建设开场白seo自动优化软件下载
  • 网站策划书的要点百度seo优化排名软件
  • 车公庙做网站网站关键词排名快速提升
  • wordpress子页面怎么修改青岛谷歌seo
  • 网站建设推广哪里实惠搜索推广出价多少合适
  • 亚马逊网站建设目的做网站的好处