当前位置:网站首页>顺序表的删除
顺序表的删除
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;
}
边栏推荐
- Qt compile error: C2228: '.key' must have class/struct/union on the left
- GVINS论文阅读笔记
- Solve rpc error: code = Unimplemented desc = method CheckLicense not implemented
- Web系统常见安全漏洞介绍及解决方案-XSS攻击
- Day113.尚医通:用户认证、阿里云OSS、就诊人管理
- 第二十三课,抗锯齿(Anti Aliasing)
- NowCoderTOP17-22 二分查找/排序——持续更新ing
- ARC在编译和运行做了什么?
- Emotional crisis, my friend's online dating girlfriend wants to break up with him, ask me what to do
- Qt 编译错误:C2228: “.key”的左边必须有类/结构/联合
猜你喜欢
随机推荐
js department budget and expenditure radar chart
Mybaits 常用问题详解
恋爱期间的赠与能否撤销
Flink1.15 source code reading flink-clients - flink command line help command
浅谈Attention与Self-Attention,一起感受注意力之美
loadrunner脚本--添加检查点
【LeetCode】118.杨辉三角
梅科尔工作室--鸿蒙十四天开发培训笔记(八)
Gradle系列——Groovy概述,基础使用(基于Groovy文档4.0.4)day2-1
(C language) program environment and preprocessing
Binary tree search and backtracking problem (leetcode)
怎样使用浏览器静默打印网页
【软考软件评测师】2012综合知识历年真题
Data Middle Office Construction (6): Data System Construction
canvas粒子变幻各种形状js特效
项目管理工具之燃尽图:动态考核团队工作能力
DC-7-vulnhub
LeetCode二叉树系列——101.对称二叉树
第五章
让动画每次重复前都有延迟









