当前位置:网站首页>顺序表的删除
顺序表的删除
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;
}
边栏推荐
猜你喜欢

Open Kylin openKylin automation developer platform officially released

第二十二课,实例化(instancing)

win10镜像下载

A Spark SQL online problem troubleshooting and positioning

Come n times - 09. Implement queues with two stacks

开放麒麟 openKylin 自动化开发者平台正式发布

Redis Sentinel原理

loadrunner-controller-手动场景Schedule配置

Build finished with errors/Executable Not Found

初识二叉搜索树
随机推荐
loadrunner-controller-目标场景Schedule配置
The big-eyed Google Chrome has also betrayed, teach you a trick to quickly clear its own ads
Progressive Web App(PWA)
业务-(课程-章节-小节)+课程发布一些业务思路
Come n times with the sword--05. Replace spaces
【职场杂谈】售前工程师岗位的理解杂谈
NowCoderTOP17-22 Binary search/sort - continuous update ing
(C语言)程序环境和预处理
loadrunner脚本--添加事务
踩水坑2 数据超出long long
The fifth chapter
【GORM】存取数组/自定义类型数据
前序、后序及层次遍历实现二叉树的序列化与反序列化
NowCoderTOP17-22 二分查找/排序——持续更新ing
【TCP/IP】Network Model
初识二叉搜索树
What is the encoding that starts with ?
[ verb phrase ] collection
Gradle series - Groovy overview, basic use (based on Groovy document 4.0.4) day2-1
SQLite3交叉编译