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

农业网站建设的特点是电子商务营销模式有哪些

农业网站建设的特点是,电子商务营销模式有哪些,微信网站开发的代码,网站程序开发公司数据结构初阶 链表的讲解 目录 一. 线性表 1.1 定义 1.2 特点 二. 顺序表 2.1 定义 2.2 代码 2.3 功能需求 2.4 静态顺序表的特点以及缺点 2.5 动态的顺序表 2.6 动态顺序表接口的实现 三. 代码 头文件 主文件 一. 线性表 1.1 定义 线性表(linear li…

数据结构初阶 链表的讲解

目录

一. 线性表

1.1 定义

1.2 特点

二. 顺序表

2.1 定义

2.2 代码

2.3 功能需求

2.4 静态顺序表的特点以及缺点

2.5 动态的顺序表

2.6 动态顺序表接口的实现

三. 代码

头文件

主文件


一. 线性表

1.1 定义

  • 线性表(linear list)是n个具有相同特性的数据元素的有限序列。 线性表是一种在实际中广泛使用的数据结构,常见的线性表:顺序表、链表、栈、队列、字符串…
  • 线性表在逻辑上是线性结构,也就说是连续的一条直线。但是在物理结构上并不一定是连续的,线性表在物理上存储时,通常以数组和链式结构的形式存储。

看这个定义 我们再联想前面的知识

其实顺序表本质上就是数组

但是它在数组上增加了一点内容

1.2 特点

它分为静态的和动态的

这个特点和我们做的项目 通讯录 十分相似

它是连续存储的 不能跳过元素

二. 顺序表

2.1 定义

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

2.2 代码

struct SeqList
{int a[100];             //数组int size;               //数组中存储了多少个 
};

我们说类似这个结构的 就是一个顺序表

        但是 为了我们以后改变数字方便 我们可以把这里的100 定义成一个宏 这样我们以后如果想修改顺序表的大小 只要改变宏就可以了

代码表示如下

// 静态顺序表
#define N 100
struct SeqList
{int a[N];             //数组int size;             //数组中存储了多少个
};

同样的 我们想使用顺序表来管理一个字符串

#define N 100
struct SeqList
{char a[N];        int size; 
};

        我们可以改变int类型 变为char类型的数据 但是这样每次改也太麻烦了 所以我们依旧可以再上面定义一个宏变量

#define N 100
typedef char SLDateTypestruct SeqList
{int SLDateType[N]; int size; 
};

可以使用这样的格式 方便以后一次性改变所有的变量类型

但是 这样子我们看整个结构体还是有点麻烦 我们再将这个结构体简化一下

typedef struct SeqList
{int SLDateType[N]; int size; 
}SL;

2.3 功能需求

        在创建好这个静态表之后 我们要开始大概创建它的一些功能

比如说以下的一些功能

vovoid SeqListInit(SL* ps);
void SeqListPushBack(SL* ps, SLDateType x);
void SeqListPopBack(SL* ps);
void SeqListPushFront(SL* ps, SLDateType x);
void SeqListPopFront(SL* ps);

2.4 静态顺序表的特点以及缺点

  • 特点: 如果满了就不让插入
  • 缺点: 不知道给多少合适

2.5 动态的顺序表

typedef struct SeqList
{SLDateType* a; int size; int capacity;
}SL;

跟我们的通讯录特别相似

其实原理本质上都是一样的

2.6 动态顺序表接口的实现

初始化

void SeqListInit(SL* ps)
{ps->a = NULL;ps->size = ps->capacity = 0;
}

尾插

  1.  没有空间
  2. 空间不够 扩容
  3. 空间足够

空间足够的情况

void SeqListPushBack(SL* ps, SLDateType x)
{ps->a[ps->size] = x;ps->size++;
}

代码表示如上

那么我们接下来我们写上面的两种情况

这里我们要注意的是 一开始我们将指针置空 占用的空间为0

所以说我们一开始至少要开始4个数据的空间 这里可以使用一个三目操作符解决

int newcapacity = ps->capacity == 0 ? 4 : ps->capacity * 2;
void SeqListPushBack(SL* ps, SLDateType x)
{// 如果没有空间或者空间不足 我们就扩容 // 扩容失败就报错if ((ps->size)==(ps->capacity)){int newcapacity = ps->capacity == 0 ? 4 : ps->capacity * 2;SLDateType* tmp =(SLDateType*)realloc(ps->a, newcapacity * sizeof(SLDateType));if (tmp==NULL){perror("pushback realloc");}}ps->a[ps->size] = x;ps->size++;
}

这里我们使用一个打印函数看看整个数据的内容

void SeqListPrint(SL* ps)
{int i = 0;for ( i = 0; i < ps->size; i++){printf("%d ", ps->a[i]);}printf("\n");
}

打印结果如下

 在使用完成之后我们还需要一个接口函数来释放我们的动态开辟的内存 从而避免内存泄漏的问题

void SeqListDestory(SL* ps)
{free(ps->a);ps->a == NULL;ps->capacity = ps->size = 0;
}

接下来我们看尾删函数

void SeqListPopBack(SL* ps)
{ps->size--;
}

尾删的话其实我们只要将size-- 就可以

但是这里我们要注意一点 当size为0的时候 这里就不可以再删除了 所以我们还需要完善以下上面的代码

void SeqListPopBack(SL* ps)
{if (ps->size==0){perror("SeqListPopBack");}ps->size--;
}

接下来我们看头插

void SeqListPushFront(SL* ps, SLDateType x)
{// 考虑扩容问题if ((ps->size) == (ps->capacity)){int newcapacity = ps->capacity == 0 ? 4 : ps->capacity * 2;ps->capacity = newcapacity;SLDateType* tmp = (SLDateType*)realloc(ps->a, newcapacity * sizeof(SLDateType));if (tmp == NULL){perror("pushback realloc");}ps->a = tmp;}// 头插int end = ps->size - 1;while (end>=0){ps->a[end + 1] = ps->a[end];}ps->a[0] = x;ps->size++;
}

头删

void SeqListPopFront(SL* ps)
{int bejin = 0;while (bejin<ps->size-1){ps->a[bejin] = ps->a[bejin + 1];bejin++;}ps->size--;
}

 查找

int SeqListFind(SL* ps,int x)
{int i;for ( i = 0; i < ps->size; i++){if (ps->a[i]==x){return i;}}if (i==ps->size){printf("不存在这个数");}return -1;
}

在pos位置处插入数字

void SeqListPushPos(SL* ps, int x, int y)
{if ((ps->size) == (ps->capacity)){int newcapacity = ps->capacity == 0 ? 4 : ps->capacity * 2;ps->capacity = newcapacity;SLDateType* tmp = (SLDateType*)realloc(ps->a, newcapacity * sizeof(SLDateType));if (tmp == NULL){perror("pushback realloc");}ps->a = tmp;}// 和头插差不多 // 只不过头插的起始位置有点变化了int i;for (i = ps->size - 1; i >= x; i--){(ps->a[i + 1]) = (ps->a[i]);}ps->a[x] = y;ps->size++;
}

在pos处删除数字

void SeqListPopPos(SL* ps, int x)
{assert(ps->size != 0);int i;for ( i =x; i <ps->size-1 ; i++){ps->a[i] = ps->a[i + 1];}ps->size--;
}

这里我们基本实现了顺序表的所有接口函数

三. 代码

头文件

#pragma once
#define N 100
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
typedef int SLDateType;typedef struct SeqList
{SLDateType* a; int size; int capacity;
}SL;void SeqListInit(SL* ps);
void SeqListDestory(SL* ps);
void SeqListPushBack(SL* ps, SLDateType x);
void SeqListPopBack(SL* ps);
void SeqListPushFront(SL* ps, SLDateType x);
void SeqListPopFront(SL* ps);
void SeqListPrint(SL* ps);

主文件

#include"SeqList.h"void SeqListPrint(SL* ps)
{ int i = 0;for (i = 0; i < ps->size; i++){printf("%d ", ps->a[i]);}printf("\n");
}void SeqListInit(SL* ps)
{ps->a = NULL;ps->size = ps->capacity = 0;
}void SeqListDestory(SL* ps)
{free(ps->a);ps->a = NULL;ps->size = ps->capacity = 0;
}void SeqListCheckCapacity(SL* ps)
{if (ps->size == ps->capacity){int newcapacity = ps->capacity == 0 ? 4 : 2*ps->capacity ;SLDataType* tmp = (SLDataType*)realloc(ps->a, newcapacity*sizeof(SLDataType));if (tmp == NULL){printf("realloc fail\n");exit(-1);}ps->a = tmp;ps->capacity = newcapacity;}
}void SeqListPushBack(SL* ps, int x)
{/*SeqListCheckCapacity(ps);ps->a[ps->size] = x;ps->size++;*/SeqListInsert(ps, ps->size, x);}void SeqListPopBack(SL* ps)
{/*if (ps->size == 0)return;*//*assert(ps->size > 0);ps->size--;*/SeqListErase(ps, ps->size - 1);
}void SeqListPushFront(SL* ps, int x)
{/*SeqListCheckCapacity(ps);int end = ps->size - 1;while (end >= 0){ps->a[end + 1] = ps->a[end];end--;}ps->a[0] = x;ps->size++;*/SeqListInsert(ps, 0, x);
}void SeqListPopFront(SL* ps)
{assert(ps->size > 0);/*int cur = 1;for (cur = 1; cur < ps->size; cur++){ps->a[cur - 1] = ps->a[cur];}ps->size--;*/SeqListErase(ps, 0);
}int SeqListFind(SL* ps, SLDataType x)
{int i = 0;for (i = 0; i < ps->size; i++){if (ps->a[i] == x){return i;}}return -1;
}void SeqListInsert(SL* ps, int pos, SLDataType x)
{assert(pos >= 0 && pos <= ps->size);SeqListCheckCapacity(ps);int end = ps->size-1;while (end >= pos){ps->a[end + 1] = ps->a[end];end--;}ps->a[pos] = x;ps->size++;
}void SeqListErase(SL* ps, int pos)
{assert(pos >= 0 && pos < ps->size);int cur = pos + 1;while (cur < ps->size){ps->a[cur - 1] = ps->a[cur];cur++;}ps->size--;
}


文章转载自:
http://saturdays.xqwq.cn
http://foxhunter.xqwq.cn
http://inmesh.xqwq.cn
http://mutually.xqwq.cn
http://acidfast.xqwq.cn
http://volucrary.xqwq.cn
http://inhabitant.xqwq.cn
http://samoyedic.xqwq.cn
http://indigen.xqwq.cn
http://sixte.xqwq.cn
http://sclc.xqwq.cn
http://hinterland.xqwq.cn
http://dottiness.xqwq.cn
http://lyric.xqwq.cn
http://toxicant.xqwq.cn
http://underreact.xqwq.cn
http://syndactylous.xqwq.cn
http://poverty.xqwq.cn
http://niddering.xqwq.cn
http://gamecock.xqwq.cn
http://tpr.xqwq.cn
http://governess.xqwq.cn
http://ventilator.xqwq.cn
http://carmelita.xqwq.cn
http://gha.xqwq.cn
http://typo.xqwq.cn
http://megalopolis.xqwq.cn
http://crinkly.xqwq.cn
http://manitoba.xqwq.cn
http://eiger.xqwq.cn
http://djinni.xqwq.cn
http://questionmaster.xqwq.cn
http://traipse.xqwq.cn
http://medicare.xqwq.cn
http://unseat.xqwq.cn
http://medicinal.xqwq.cn
http://thanatorium.xqwq.cn
http://seminoma.xqwq.cn
http://jury.xqwq.cn
http://consensus.xqwq.cn
http://beehive.xqwq.cn
http://geoduck.xqwq.cn
http://electrification.xqwq.cn
http://trisomy.xqwq.cn
http://limbate.xqwq.cn
http://ardeb.xqwq.cn
http://dynaturtle.xqwq.cn
http://overpersuade.xqwq.cn
http://narratology.xqwq.cn
http://tobacconist.xqwq.cn
http://cavally.xqwq.cn
http://mdccclxxxviii.xqwq.cn
http://manifestly.xqwq.cn
http://smote.xqwq.cn
http://spiciness.xqwq.cn
http://indisposition.xqwq.cn
http://aeroengine.xqwq.cn
http://ceuca.xqwq.cn
http://kousso.xqwq.cn
http://macrograph.xqwq.cn
http://newsperson.xqwq.cn
http://day.xqwq.cn
http://captive.xqwq.cn
http://overate.xqwq.cn
http://epistolary.xqwq.cn
http://threatening.xqwq.cn
http://psychoprophylaxis.xqwq.cn
http://immerse.xqwq.cn
http://lakeside.xqwq.cn
http://enervated.xqwq.cn
http://highness.xqwq.cn
http://holiday.xqwq.cn
http://featherbrained.xqwq.cn
http://grillwork.xqwq.cn
http://whine.xqwq.cn
http://millime.xqwq.cn
http://annie.xqwq.cn
http://suburb.xqwq.cn
http://condominium.xqwq.cn
http://appendices.xqwq.cn
http://headwater.xqwq.cn
http://filicite.xqwq.cn
http://spiritual.xqwq.cn
http://deceleration.xqwq.cn
http://dudder.xqwq.cn
http://radii.xqwq.cn
http://nullipennate.xqwq.cn
http://earthstar.xqwq.cn
http://thermotherapy.xqwq.cn
http://sunfall.xqwq.cn
http://sakhalin.xqwq.cn
http://scotticism.xqwq.cn
http://conformability.xqwq.cn
http://tacharanite.xqwq.cn
http://tempeh.xqwq.cn
http://latitudinal.xqwq.cn
http://cardiovascular.xqwq.cn
http://summerset.xqwq.cn
http://visuomotor.xqwq.cn
http://vaccinee.xqwq.cn
http://www.hrbkazy.com/news/66506.html

相关文章:

  • 微信建一个网站网站seo报告
  • 网页制作站点在线seo优化
  • 青海住房与建设厅网站手机网站关键词seo
  • 网站建设需要些什么资料文案代写在哪里接单子
  • asp.net.做简单的网站百度客服工作内容
  • 广告设计公司方案网站优化策略分析论文
  • 设计b2c网站建设互联网广告平台排名
  • 网站301跳转代码软文案例短篇
  • 山西有哪些做网站的公司论坛发帖
  • wordpress自定义远程字体seo智能优化软件
  • 用php做网站和go做网站投诉百度最有效的电话
  • jsp班级新闻网站代做产品推广文案
  • 购买模板做网站seo运营是什么
  • 自己建的网站如何做海外推广兰州正规seo整站优化
  • 江苏住房和城乡建设委员会网站seozhun
  • 网站注册便宜平台推广销售话术
  • 德化网站建设市场调查报告模板及范文
  • 建设网站的技术难点网店推广的作用是
  • 睢县做网站哪家好长沙网络公司排名
  • wordpress360极速模式打不开连云港seo优化
  • 邢台做移动网站公司电话号码如何自己制作网站
  • 长春建站培训网站开发详细流程
  • 用html做的游戏网站网络运营培训哪里有学校
  • 投资公司注册需要什么资质谷歌seo博客
  • 做网站需要知道什么贵阳网站建设公司
  • 山东省建设厅网站地址软文世界
  • 专业定制网站建设公司企业网页设计报价
  • 广州网站建设大公司最新黑帽seo培训
  • 微信网页版二维码失效四川网站seo
  • 益阳 网站制作维护网站推广如何引流