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

手机网站制作哪家好采集站seo赚钱辅导班

手机网站制作哪家好,采集站seo赚钱辅导班,3. 是网站建设的重点,单页面网站现在定义: 顺序表存储定义: 把逻辑上相邻的数据元素存储在物理上相邻的存储单元中的存储结构,顺序表功能的实现借助于数组,通过对数组进行封装,从而实现增删查改的功能,严格意义上来说(数组无法实现…

定义:

顺序表存储定义: 把逻辑上相邻的数据元素存储在物理上相邻的存储单元中的存储结构,顺序表功能的实现借助于数组,通过对数组进行封装,从而实现增删查改的功能,严格意义上来说(数组无法实现删除数据的功能)。

#define _CRT_SECURE_NO_WARNINGS 1
#include"seqlist.h"void initseqlist(SL* p) {assert(p);p->arr = NULL;p->capacity = p->size = 0;
}void printseqlist(SL* p) {for (int i = 0; i < p->size; i++) {printf("%d ", p->arr[i]);}printf("\n");
}void checkcapacity(SL* p) {assert(p);if (p->capacity == p->size) {int newcapacity = p->capacity == 0 ? 4 : 2 * p->capacity;// if here use malloc,the origin data in this array might be missing int* temp = (int*)realloc(p->arr,sizeof(int) * newcapacity);p->arr = temp;p->capacity = newcapacity;}
}void pushFront(SL* p, int val) {assert(p);checkcapacity(p);int end = p->size - 1;while (end >= 0) {p->arr[end + 1] = p->arr[end];end--;}p->arr[0 ] = val;p->size++;
}void pushback(SL* p,int val) {//assert(p);checkcapacity(p);p->arr[p->size] = val;p->size++;
}void popfront(SL* p) {assert(p);int n = p->arr[0];printf("将要被pop元素=%d\n", n);for (int i = 1; i < p->size ; i++) {p->arr[i - 1] = p->arr[i];}p->size--;
}void insertanyposition(SL* p, int pos, int val) {assert(p);assert(pos >= 0 && pos <= p->size);int end = p->size - 1;while (end>=pos) {p->arr[end + 1] = p->arr[end];end--;}p->arr[pos] = val;p->size++;
}int findDataPos(SL* p, int val) {assert(p);for (int i = 0; i < p->size; i++) {if (p->arr[i] == val) {return i;}}return -1;
}

1、顺序表的初始化:

typedef struct seqlist {int* arr;int size;int capacity;
}SL,*PTR;void initseqlist(SL* p) {assert(p);p->arr = NULL;p->capacity = p->size = 0;
}

 

2、顺序表容量检测:

当我们要对表里进行相关操作的时候,第一步检测当下该表中size 与 容量的关系,可以写一个checkcapacity函数。

void checkcapacity2(SL* p) {assert(p);if (p->capacity == p->size) {int newcapacity = p->capacity == 0 ? 4 : 2 * p->capacity;int* temp = (int*)malloc(sizeof(int) * newcapacity);p->arr = temp;p->capacity = newcapacity;}
}void test3() {PTR p;SL sl;p = &sl;initseqlist(p);pushback(p, 5);//first init  ---> size=4,capacity=4pushback(p, 15);pushback(p, 25);pushback(p, 35);pushback(p, 45);printseqlist(p);}

这个时候来看一下打印结果:

为什么会这样呢,这个时候我们就需要借助调试工具来找出问题所在

所以我们该处可以用realloc 函数 来进行动态内存管理:

void checkcapacity(SL* p) {assert(p);if (p->capacity == p->size) {int newcapacity = p->capacity == 0 ? 4 : 2 * p->capacity;// if here use malloc,the origin data in this array might be missing int* temp = (int*)realloc(p->arr,sizeof(int) * newcapacity);p->arr = temp;p->capacity = newcapacity;}
}

 

 

3、顺序表插入数据:

3.1头插:

void pushFront(SL* p, int val) {assert(p);checkcapacity(p);int end = p->size - 1;while (end >= 0) {p->arr[end + 1] = p->arr[end];end--;}p->arr[0 ] = val;p->size++;
}

 

 

3.2尾插:

void pushback(SL* p,int val) {//assert(p);checkcapacity(p);p->arr[p->size] = val;p->size++;
}

4、顺序表删除数据:

4.1头删

void popfront(SL* p) {assert(p);int n = p->arr[0];// 可以起到记录作用printf("将要被pop元素=%d\n", n);for (int i = 1; i < p->size ; i++) {p->arr[i - 1] = p->arr[i];}p->size--;
}

 

4.2尾删

5、任意位置实现插入功能:

void insertanyposition(SL* p, int pos, int val) {assert(p);assert(pos >= 0 && pos <= p->size);int end = p->size - 1;while (end>=pos) {p->arr[end + 1] = p->arr[end];end--;}p->arr[pos] = val;p->size++;
}

6、顺序表中实现查找功能:

int findDataPos(SL* p, int val) {assert(p);for (int i = 0; i < p->size; i++) {if (p->arr[i] == val) {return i;}}return -1;
}

http://www.dinnco.com/news/87007.html

相关文章:

  • 一起做网站360网站推广费用
  • 三层架构做网站还是系统百度商城app下载
  • 工作蒸蒸日上seo工具
  • 网站建设项目验收付款班级优化大师学生版
  • 免备案wordpress主机安卓系统优化大师
  • 医院做网站备案需要哪些资料百度收录链接提交入口
  • 郑州做网站外包的公司有哪些正规优化公司哪家好
  • wordpress使用插件搜索seo怎么优化
  • 做品牌设计网站整合营销名词解释
  • 做英语阅读的网站舆情服务公司
  • 如何做网站模特百度seo快速
  • 网站建设需经历的步骤如何推广公司
  • 团风做网站上海免费关键词排名优化
  • 天门网站建设seo关键词排名优化报价
  • 网站管理员权限设置如何给网站做推广
  • 成都建站模板网站制作网站推广排名教程
  • 上海市建设信息网官网成都网站seo公司
  • 网站建设和成本武汉seo报价
  • 免费的模板网站2022最新热点事件及点评
  • 网站建设与维护成本seo项目优化案例分析文档
  • 深圳积分商城网站设计网址提交
  • 外包做网站多少钱郑州seo外包费用
  • 好用的做微信公众号的网站重庆网站设计
  • 西安企业网站制作百度快照关键词推广
  • 做web的网站设计免费crm网站不用下载的软件
  • 做网站的登陆功能it培训机构
  • 扁平化蓝色网站免费影视软件靠什么赚钱
  • 网站成立查询乐陵seo外包公司
  • 仿淘宝电商网站开发报价中国网络推广网站排名
  • 免费网站你懂我意思正能量软件新闻发稿平台有哪些