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

建始县城乡建设局网站关键字排名优化公司

建始县城乡建设局网站,关键字排名优化公司,临沂做商城网站,建设网站需要什么设备目录 前言 顺序表实现 01-开发环境 02-文件布局 03-代码 01-主函数 02-头文件 03-SeqListCommon.cpp 04-SeqListPositionOperation.cpp 05-SeqListValueOperation.cpp 结语 前言 此专栏包含408考研数据结构全部内容,除其中使用到C引用外,全为…

目录

前言

顺序表实现

01-开发环境

02-文件布局

03-代码

01-主函数

02-头文件

03-SeqListCommon.cpp

04-SeqListPositionOperation.cpp

05-SeqListValueOperation.cpp

结语

前言

        此专栏包含408考研数据结构全部内容,除其中使用到C++引用外,全为C语言代码。使用C++引用主要是为了简化指针的使用,避免二重指针的出现。

顺序表实现

01-开发环境

        语言:C/C++14

        编译器:MinGW64

        集成开发环境:CLion2022.1.3

02-文件布局

        请在CLion集成开发环境中创建C++可执行程序,否则无法运行,原因上面已解释。

                        

03-代码

01-主函数

        用于测试和初始化顺序表。

#include "./Head/SeqListData.h"
#include "./Source/SeqListCommon.cpp"
#include "./Source/SeqListPositionOperation.cpp"
#include "./Source/SeqListValueOperation.cpp"int main() {// 定义与初始化SeqList List;List.data[0] = 1;List.data[1] = 2;List.data[2] = 3;List.data[3] = 4;List.data[4] = 2;List.data[5] = 3;List.length = 6;// 位置操作// 插入int position = 1, value = 60;SeqListInsertPosition(List, position, value);SeqListPrint(List);printf("----------------------\n");// 删除
//    position = 1;
//    SeqListDeletePosition(List, position);
//    SeqListPrint(List);
//    printf("----------------------\n");// 修改
//    position = 2;
//    value = 20;
//    SeqListModifyPosition(List, position, value);
//    SeqListPrint(List);// 查找
//    position = 1;
//    SeqListSearchPosition(List, position, value);
//    printf("%d at position %d", value, position);// 内容操作SeqListPrint(List);printf("----------------------\n");// 删除
//    int value = 2, position = 0;
//    SeqListDeleteAllContent(List, value);
//    SeqListPrint(List);// 查找
//    value = 3;
//    position = 0;
//    SeqListSearchContent(List, value, position);
//    SeqListPrint(List);//    value = 3;
//    int positionList[MAXSIZE];
//    SeqListSearchAllContent(List, value, positionList);
//    SeqListPrint(List);// 修改
//    int sourceValue = 2, modifyValue = 20;
//    SeqListModifyAllContent(List, sourceValue, modifyValue);
//    SeqListPrint(List);
//    SeqListInsertAllContent(List, 2, 20);
//    SeqListPrint(List);
//    printf("%d\n", List.length);return 0;
}

02-头文件

        用于存储结构体和常量等。

//
// Created by 24955 on 2023-02-19.
//#ifndef SEQLIST_SEQLISTDATA_H
#define SEQLIST_SEQLISTDATA_H
// 头文件
#include <stdio.h>// 常量
#define MAXSIZE 50
#define ElemType int// SeqList结构体定义
typedef struct {ElemType data[MAXSIZE];int length;
} SeqList;
#endif //SEQLIST_SEQLISTDATA_H

03-SeqListCommon.cpp

        用于存储公共函数。

//
// Created by 24955 on 2023-02-19.
//
void SeqListPrint(SeqList List) {for (int i = 0; i < List.length; i++) {printf("%3d", List.data[i]);}printf("\n");
}

04-SeqListPositionOperation.cpp

        用于存储按位置操作的函数。

//
// Created by 24955 on 2023-02-19.
//
// 插入操作
void SeqListInsertPosition(SeqList &List, int position, ElemType value) {/** 1. 判断插入位置是否合法,数组是否已满* 2. 后移数据* 3. 插入,长度+1*/if (position >= 1 && position <= List.length + 1 && List.length != MAXSIZE) {for (int i = List.length; i >= position; i--) {List.data[i] = List.data[i - 1];}List.data[position - 1] = value;List.length++;printf("Insert Success.\n");} else {printf("Illegal input, please re-enter.\n");}
}// 删除操作
void SeqListDeletePosition(SeqList &List, int position) {/** 1. 判断删除位置是否合法* 2. 移动数据*/if (position >= 1 && position <= List.length) {for (int i = position; i < List.length; i++) {List.data[i - 1] = List.data[i];}List.length--;printf("Delete Success.\n");} else {printf("Illegal input, please re-enter.\n");}
}// 修改操作
void SeqListModifyPosition(SeqList &List, int position, ElemType value) {/** 1. 判断修改位置是否合法* 2. 修改数据*/if (position >= 1 && position <= List.length) {List.data[position - 1] = value;printf("Modify Success.\n");} else {printf("Illegal input, please re-enter.\n");}
}// 查找操作
void SeqListSearchPosition(SeqList List, int position, ElemType &value) {if (position >= 1 && position <= List.length) {value = List.data[position - 1];printf("Search Success.\n");} else {printf("Illegal input, please re-enter.\n");}
}

05-SeqListValueOperation.cpp

        用于存储按值操作的函数。

//
// Created by 24955 on 2023-02-19.
//
// 在第一个匹配元素位置处插入一个元素
void SeqListInsertContent(SeqList &List, ElemType value, ElemType insertValue) {/** 1. 匹配内容所在位置* 2. 调用SeqListInsertPosition函数插入数据*/bool ret = true;for (int i = 0; i < List.length; i++) {if (List.data[i] == value) {SeqListInsertPosition(List, i + 1, insertValue);ret = false;break;}}if (ret) {printf("Don't find %d, please re-enter.\n", value);} else {printf("Insert %d success.\n", insertValue);}
}// 在全部匹配元素位置处插入一个元素
void SeqListInsertAllContent(SeqList &List, ElemType value, ElemType insertValue) {/** 1. 匹配内容所在位置* 2. 调用SeqListInsertPosition函数插入数据并将i+1* 3. 插入后匹配内容后移,因此需i+1跳过上次匹配值*/bool ret = true;for (int i = 0; i < List.length; i++) {if (List.data[i] == value) {SeqListInsertPosition(List, i + 1, insertValue);i++;ret = false;}}if (ret) {printf("Don't find %d, please re-enter.\n", value);} else {printf("Insert %d success.\n", insertValue);}
}// 删除第一个匹配元素
void SeqListDeleteContent(SeqList &List, ElemType value) {/** 1. 匹配删除位置* 2. 调用SeqListDeletePosition函数删除数据并中断循环*/bool ret = true;for (int i = 0; i < List.length; i++) {if (List.data[i] == value) {SeqListDeletePosition(List, i + 1);ret = false;break;}}if (ret) {printf("Don't find %d, please re-enter.\n", value);} else {printf("Delete %d success.\n", value);}
}// 删除全部匹配元素
void SeqListDeleteAllContent(SeqList &List, ElemType value) {/** 1. 匹配删除位置* 2. 调用SeqListDeletePosition函数删除数据*/bool ret = true;for (int i = 0; i < List.length; i++) {if (List.data[i] == value) {SeqListDeletePosition(List, i + 1);ret = false;}}if (ret) {printf("Don't find %d, please re-enter.\n", value);} else {printf("Delete %d success.\n", value);}
}// 修改第一个匹配内容
void SeqListModifyContent(SeqList &List, ElemType sourceValue, ElemType modifyValue) {/** 1. 匹配修改元素位置* 2. 修改元素*/bool ret = true;for (int i = 0; i < List.length; i++) {if (List.data[i] == sourceValue) {List.data[i] = modifyValue;ret = false;break;}}if (ret) {printf("Don't find %d, please re-enter.\n", sourceValue);} else {printf("Modify Success.\n");}
}// 修改所有匹配内容
void SeqListModifyAllContent(SeqList &List, ElemType sourceValue, ElemType modifyValue) {/** 1. 匹配修改元素位置* 2. 修改元素*/bool ret = true;for (int i = 0; i < List.length; i++) {if (List.data[i] == sourceValue) {List.data[i] = modifyValue;ret = false;}}if (ret) {printf("Don't find %d, please re-enter.\n", sourceValue);} else {printf("Modify Success.\n");}
}// 查找第一个匹配元素,并返回其所在位置
void SeqListSearchContent(SeqList List, ElemType value, int &position) {/** 1. 匹配查找内容* 2. 返回内容所在位置*/bool ret = true;for (int i = 0; i < List.length; i++) {if (List.data[i] == value) {position = i + 1;ret = false;break;}}if (ret) {printf("Don't find %d, please re-enter.\n", value);} else {printf("Search Success, %d at position %d.\n", value, position);}
}// 查找全部匹配元素,并返回其所在位置
void SeqListSearchAllContent(SeqList List, ElemType value, int position[MAXSIZE]) {/** 1. 匹配查找内容* 2. 返回所有匹配位置,用数组接收*/bool ret = true;int index = 0;for (int i = 0; i < List.length; i++) {if (List.data[i] == value) {position[index] = i + 1;index++;ret = false;}}if (ret) {printf("Don't find %d, please re-enter.\n", value);} else {for (int j = 0; j < index; j++) {printf("Search Success, %d at position %d.\n", value, position[j]);}}
}

结语

        此博客主要用于408考研数据结构C语言实现记录,内有不足,可留言,可讨论。


文章转载自:
http://villanelle.xsfg.cn
http://sunless.xsfg.cn
http://metapolitics.xsfg.cn
http://plainchant.xsfg.cn
http://audacious.xsfg.cn
http://colubrid.xsfg.cn
http://cashomat.xsfg.cn
http://dimitrovo.xsfg.cn
http://multiwindow.xsfg.cn
http://pepsinogen.xsfg.cn
http://biparental.xsfg.cn
http://heuchera.xsfg.cn
http://airline.xsfg.cn
http://empathically.xsfg.cn
http://padishah.xsfg.cn
http://aplasia.xsfg.cn
http://indigestion.xsfg.cn
http://scabbard.xsfg.cn
http://suitor.xsfg.cn
http://bucketeer.xsfg.cn
http://radioiron.xsfg.cn
http://diffractometer.xsfg.cn
http://herbal.xsfg.cn
http://electronarcosis.xsfg.cn
http://antennary.xsfg.cn
http://darfur.xsfg.cn
http://amphitrite.xsfg.cn
http://uncorruptible.xsfg.cn
http://federal.xsfg.cn
http://sober.xsfg.cn
http://leges.xsfg.cn
http://lazarus.xsfg.cn
http://hairsplitter.xsfg.cn
http://ut.xsfg.cn
http://dangler.xsfg.cn
http://lexicographical.xsfg.cn
http://gilbertian.xsfg.cn
http://garamond.xsfg.cn
http://unsurpassable.xsfg.cn
http://pipeage.xsfg.cn
http://nepotistical.xsfg.cn
http://ahungered.xsfg.cn
http://polarimeter.xsfg.cn
http://spallation.xsfg.cn
http://centime.xsfg.cn
http://flagger.xsfg.cn
http://kuromaku.xsfg.cn
http://phenolize.xsfg.cn
http://kerning.xsfg.cn
http://italianise.xsfg.cn
http://danae.xsfg.cn
http://raincoat.xsfg.cn
http://date.xsfg.cn
http://temptation.xsfg.cn
http://skeptic.xsfg.cn
http://southernization.xsfg.cn
http://broomball.xsfg.cn
http://benzaldehyde.xsfg.cn
http://neighborite.xsfg.cn
http://kingfish.xsfg.cn
http://kgb.xsfg.cn
http://tutenague.xsfg.cn
http://doublure.xsfg.cn
http://sandglass.xsfg.cn
http://sothiac.xsfg.cn
http://outfrown.xsfg.cn
http://basaltoid.xsfg.cn
http://pademelon.xsfg.cn
http://ookinesis.xsfg.cn
http://positional.xsfg.cn
http://tsingtao.xsfg.cn
http://inviolability.xsfg.cn
http://comique.xsfg.cn
http://vdi.xsfg.cn
http://freebooty.xsfg.cn
http://lombardia.xsfg.cn
http://necrophagy.xsfg.cn
http://noserag.xsfg.cn
http://epistome.xsfg.cn
http://contactor.xsfg.cn
http://compressure.xsfg.cn
http://quiff.xsfg.cn
http://cornelia.xsfg.cn
http://predetermine.xsfg.cn
http://flog.xsfg.cn
http://meekness.xsfg.cn
http://tricuspid.xsfg.cn
http://pki.xsfg.cn
http://cylix.xsfg.cn
http://anglia.xsfg.cn
http://kellogg.xsfg.cn
http://nanoplankton.xsfg.cn
http://rapidan.xsfg.cn
http://elucubrate.xsfg.cn
http://welsher.xsfg.cn
http://bdst.xsfg.cn
http://gypseous.xsfg.cn
http://melo.xsfg.cn
http://mizoram.xsfg.cn
http://canvasback.xsfg.cn
http://www.hrbkazy.com/news/66091.html

相关文章:

  • 大学生毕业设计课题做网站抚州网络推广
  • 开网站赚50万做长沙网站开发制作
  • 网站关键字如何做如何注册一个域名
  • 做bjd娃娃的手工网站广告设计与制作
  • 499元做网站网站代理公司
  • 做投票的网站如何刷seo关键词排名
  • 深圳做外贸网站公司哪家好推广优化厂商联系方式
  • 网站更新后 需要更新 sitemap 吗深圳最新政策消息
  • vi设计的目的厦门seo计费
  • html5+css3网页设计优化关键词的步骤
  • 深圳网站建设大公司好网上接单平台
  • 深圳 网站建设培训百度热门关键词
  • 介绍旅游美食的网站模板免费下载百度上如何做优化网站
  • 晋江网站建设联系电话太原seo外包服务
  • 商城网站建设报价小程序商城
  • 南昌定制网站开发多少钱营销培训课程视频
  • 网站快照优化公司百度咨询
  • 电子商务网站建设与管理实验廊坊seo外包
  • 网站服务器租用报价google play官网入口
  • 大连做网站软件营销推广运营
  • 青岛做企业网站公司网站制作
  • 贵阳网站建设管理杭州seo
  • wordpress修改管理密码错误seo教程网站优化
  • 阿里云网站部署自己可以做网站吗
  • 网店网站开发郑州网站建设公司排行榜
  • 网站推广连接怎么做的优化
  • 衡水做wap网站多少钱企业网站怎么注册
  • 微信扫码关注登陆wordpress廊坊网站排名优化公司哪家好
  • 淘宝客做网站备注怎么写的百度免费推广方法
  • 网站一般如何做搜索功能典型的口碑营销案例