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

沧州高端网站制作uni做网站首页

沧州高端网站制作,uni做网站首页,开发软件怎么开发,3千元在家办厂简介#xff1a;本系列博客为C项目系列内容#xff0c;通过代码来具体实现某个经典简单项目 适宜人群#xff1a;已大体了解C语法同学 作者留言#xff1a;本博客相关内容如需转载请注明出处#xff0c;本人学疏才浅#xff0c;难免存在些许错误#xff0c;望留言指正 作… 简介本系列博客为C项目系列内容通过代码来具体实现某个经典简单项目 适宜人群已大体了解C语法同学 作者留言本博客相关内容如需转载请注明出处本人学疏才浅难免存在些许错误望留言指正 作者博客链接睡觉待开机 下面是本项目的大体思路梳理 引言 一般来说顺序表作为基本的数据结构类型是不需要我们进行实现的因为一些高级语言比如C或者java直接具备的这样的内置数据结构但是为了深入了解顺序表的底层这里也是建议自己动手用C写一下一是便于复习C学到的知识二是更加深入了解顺序表的实现底层逻辑。 1.顺序表思路 为了明晰顺序表的实现思路我们首先来铺垫一下我到底要在怎么写一个顺序表。 首先啥是顺序表 一种线性表底层是数组只不过这个顺序表所谓的数组不单单可以放各种类型的数据还可以有各种接口包括增删查改操作的接口等等。 注线性表的概念逻辑结构上是连续的物理结构不一定连续的数据结构称为线性表。 顺序表的概念逻辑结构上是连续的物理结构上也是连续的底层是以数组为实现有着增删查改各种接口的基本数据组织结构。 那么我就可以大致明白了我要写一个顺序表这个顺序表实现了一些功能。 首先我要写一个顺序表的话要有一个顺序表的大体类型吧所以我就写了一个动态顺序表的类型 typedef int SLDateType;typedef struct SeqList {SLDateType* arr;int size;int capacity; }SL;然后我想要在这个顺序表中实现各种功能接口那这个顺序表首先得初始化吧有初始化顺序表了那肯定对应着销毁这个接口自然也需要顺序表销毁然后还要有头插尾插任意插入这个”增“的功能还有有头删尾删任意删的这个”删“的共能然后还要有查找功能还要修改功能那么我针对该顺序表的每个接口专门搞一个函数 为了便于代码书写我将各种接口以及顺序表类型本身定义在SeqList.h头文件中进行声明与定义 #pragma once #includestdio.h #includeassert.h #includestdlib.htypedef int SLDateType;typedef struct SeqList {SLDateType* arr;int size;int capacity; }SL;//初始化和销毁 void SLInit(SL* ps); void SLDestroy(SL* ps); void SLPrint(SL* ps);//顺序表的头部输入/尾部输入 void SLPushBack(SL* ps,SLDateType x); void SLPushFront(SL* ps, SLDateType x);//顺序表的头部删除/尾部删除 void SLPopBack(SL* ps); void SLPopFront(SL* ps);//指定位置放入/删除数据 void SLInsert(SL* ps, int pos, SLDateType x); void SLErase(SL* ps, int pos);//查找数据 int SLFind(SL* ps, SLDateType x);//修改数据 void SLModify(SL* ps, int pos, SLDateType x); 2.具体实现各种接口 顺序表初始化接口 void SLInit(SL* ps) {assert(ps);ps-arr NULL;ps-capacity ps-size 0; }顺序表初始化插图 顺序表销毁接口 void SLDestroy(SL* ps) {assert(ps);if (ps-arr){free(ps-arr);}ps-arr NULL;ps-capacity ps-size 0; }顺序表销毁插图 顺序表扩容接口 void SLCheckCapacity(SL* ps) {assert(ps);if (ps-capacity ps-size){//小问题刚开始的时候sl-capacity是0值int newcapacity ps-capacity 0 ? 4 : 2 * ps-capacity;SLDateType* temp realloc(ps-arr,sizeof(SLDateType)*newcapacity);if (!temp){perror(realloc fail!);return;}ps-arr temp;ps-capacity newcapacity;} }顺序表扩容插图 顺序表插入接口 void SLPushBack(SL* ps,SLDateType x) {assert(ps);//1.空间不足需要扩大容量//2.空间足够直接放入数据SLCheckCapacity(ps);ps-arr[ps-size] x;ps-size; }void SLPushFront(SL* ps, SLDateType x) {assert(ps);SLCheckCapacity(ps);//挪动数据int i 0;for (i ps-size - 1; i 0; i--){ps-arr[i1] ps-arr[i];}//放入数据*(ps-arr) x;ps-size; } void SLInsert(SL* ps, int pos, SLDateType x) {assert(ps);assert(pos 0 pos ps-size);SLCheckCapacity(ps);int i 0;for (i ps-size - 1; i pos; i--){ps-arr[i1] ps-arr[i];}ps-arr[pos] x;ps-size; }头插的插图 尾插的插图 任意插入的插图 顺序表删除接口 void SLPopBack(SL* ps) {assert(ps);assert(ps-size);ps-size--; }void SLPopFront(SL* ps) {assert(ps);assert(ps-size);int i 0;for (i 1; i ps-size; i){ps-arr[i-1] ps-arr[i];}ps-size--; } void SLErase(SL* ps, int pos) {assert(ps);assert(pos 0 pos ps-size);int i 0;for (i pos 1; i ps-size; i){ps-arr[i-1] ps-arr[i];}ps-size--; }头删插图 尾删插图 任意删插图 顺序表查找接口 int SLFind(SL* ps, SLDateType x) {assert(ps);int i 0;for (i 0; i ps-size; i){if (x ps-arr[i]){printf(%d找到了:,x);return i;}}printf(没有找到\n);return -1; }顺序表修改接口 void SLModify(SL* ps, int pos, SLDateType x) {assert(ps);assert(pos 0 pos ps-size - 1);ps-arr[pos] x;printf(修改成功\n); } 修改插图 3.全部接口代码实现 #includeSeqList.hvoid SLCheckCapacity(SL* ps) {assert(ps);if (ps-capacity ps-size){//小问题刚开始的时候sl-capacity是0值int newcapacity ps-capacity 0 ? 4 : 2 * ps-capacity;SLDateType* temp realloc(ps-arr,sizeof(SLDateType)*newcapacity);if (!temp){perror(realloc fail!);return;}ps-arr temp;ps-capacity newcapacity;} }void SLInit(SL* ps) {assert(ps);ps-arr NULL;ps-capacity ps-size 0; }void SLDestroy(SL* ps) {assert(ps);if (ps-arr){free(ps-arr);}ps-arr NULL;ps-capacity ps-size 0; }void SLPrint(SL* ps) {assert(ps);int i 0;for (i 0; i ps-size; i){printf(%d , *(ps-arr i));//ps-arr[i];}printf(\n); }void SLPushBack(SL* ps,SLDateType x) {assert(ps);//1.空间不足需要扩大容量//2.空间足够直接放入数据SLCheckCapacity(ps);ps-arr[ps-size] x;ps-size; }void SLPushFront(SL* ps, SLDateType x) {assert(ps);SLCheckCapacity(ps);//挪动数据int i 0;for (i ps-size - 1; i 0; i--){ps-arr[i1] ps-arr[i];}//放入数据*(ps-arr) x;ps-size; }void SLPopBack(SL* ps) {assert(ps);assert(ps-size);ps-size--; }void SLPopFront(SL* ps) {assert(ps);assert(ps-size);int i 0;for (i 1; i ps-size; i){ps-arr[i-1] ps-arr[i];}ps-size--; }void SLInsert(SL* ps, int pos, SLDateType x) {assert(ps);assert(pos 0 pos ps-size);SLCheckCapacity(ps);int i 0;for (i ps-size - 1; i pos; i--){ps-arr[i1] ps-arr[i];}ps-arr[pos] x;ps-size; }void SLErase(SL* ps, int pos) {assert(ps);assert(pos 0 pos ps-size);int i 0;for (i pos 1; i ps-size; i){ps-arr[i-1] ps-arr[i];}ps-size--; }int SLFind(SL* ps, SLDateType x) {assert(ps);int i 0;for (i 0; i ps-size; i){if (x ps-arr[i]){printf(%d找到了:,x);return i;}}printf(没有找到\n);return -1; }void SLModify(SL* ps, int pos, SLDateType x) {assert(ps);assert(pos 0 pos ps-size - 1);ps-arr[pos] x;printf(修改成功\n); } 完。
http://www.hkea.cn/news/14467570/

相关文章:

  • 公网动态ip如何做网站济南住建局官方网站
  • 网站开发移动app开发小程序需要的技术
  • 美工外包网站西安便宜的网站建设
  • 红色企业网站源码网站设计公司销售渠道建设
  • 站长工具seo综合查询全面解析平台推广员是做什么的
  • 公司网页网站建艺术生搭建wordpress个人博客
  • 山西省建设厅网站查询什么对网站建设起到计划和指导作用
  • 用安卓做网站外贸公司名字大全
  • 东莞万江网站制作网站做的长图能导出吗
  • 白水网站建设青岛seo博客
  • 求一个做健身餐的网站网络营销网站 功能
  • 网站开发 有哪些优化功能四川建设集团有限公司网站
  • 淄博网站设计方案seo推广关键词公司
  • 中国十大购物网站排行榜滨江做网站
  • 门户手机网站开发从化做网站开发
  • 毕业设计资源网站金融网站模板免费下载
  • 网站建设 海拉尔网站项目的流程
  • 网站开发工程师公司兰州微信小程序制作公司
  • 珠海公司网站域名注册黄骅市属于沧州吗
  • 平顶山做网站优化数棋网站建设
  • 汕头网站建设找千素网阿里云主机做网站
  • 怎么推广我的网站免费详情页模板网站
  • 网站预订模板怎么做营销网站定制公司
  • 巩义旅游网站设计公司设计网站源代码
  • 做网站先做前台还是后台谷歌网站地图生成
  • 网站优化排名易下拉软件网店美工课本
  • 怎样把域名和做的网站连接不上大规模网站
  • dtcms网站开发订单详情页面设计
  • 网站建设个人工作总结扬州网络推广公司
  • 网站开发工具最好用昆明seo排名外包