当前位置:网站首页>顺序表的删除
顺序表的删除
2022-07-31 10:08:00 【柯基@】
以顺序表存放的数据是整数类型为例 ~
- 按位序删除
bool ListDelete(SqList &L,int i,int &e){
if(i<1||i>L.length) // i为位序
return false;
e=L.data[i-1];
for(int j=i;j<=L.length-1;j++){
//前移
L.data[j-1]=L.data[j];
}
L.length--;
return true;
}
- 按下标删除
bool ListDelete(SqList &L,int i,int &e){
if(i<0||i>L.length-1) // i为下标
return false;
e=L.data[i];
for(int j=i+1;j<=L.length-1;j++){
//前移
L.data[j-1]=L.data[j];
}
L.length--;
return true;
}
边栏推荐
- Redis的简单使用
- Mybaits Frequently Asked Questions Explained
- Implement a thread pool
- 解决rpc error: code = Unimplemented desc = method CheckLicense not implemented
- nodeJs--url模块
- (C language) program environment and preprocessing
- VMware下安装win10
- Web系统常见安全漏洞介绍及解决方案-sql注入
- Meikle Studio--Hongmeng 14-day development training notes (8)
- [NLP] Interpretation of Transformer Theory
猜你喜欢
js right dot single page scrolling introduction page
Day113.尚医通:用户认证、阿里云OSS、就诊人管理
Flink1.15 source code reading - PER_JOB vs APPLICATION execution process
Web系统常见安全漏洞介绍及解决方案-XSS攻击
第五章
Come n times - 07. Rebuild the binary tree
Burndown chart of project management tools: Dynamic assessment of team work ability
centos7安装mysql5.7
csdn file export to pdf
[NLP] Interpretation of Transformer Theory
随机推荐
Source code analysis of GZIPInputStream class
数字加分隔符
第五章
SQLite3交叉编译
前序、后序及层次遍历实现二叉树的序列化与反序列化
VMware下安装win10启动后进入Boot Manger界面如何解决
&#x开头的是什么编码?
Build finished with errors/Executable Not Found
第七章
Rich text editor Tinymce
【LeetCode】Day108-和为 K 的子数组
[NLP] Interpretation of Transformer Theory
NowCoderTOP23-27 Binary tree traversal - continuous update ing
如何在 TiDB Cloud 上使用 Databricks 进行数据分析 | TiDB Cloud 使用指南
Gradle series - Groovy overview, basic use (based on Groovy document 4.0.4) day2-1
【TCP/IP】Network Model
OpenGL es 初识
NowCoderTOP17-22 Binary search/sort - continuous update ing
湖仓一体电商项目(二):项目使用技术及版本和基础环境准备
matlab 读取csv文件绘图