当前位置:网站首页>Class question: how to ensure that line table storage can be inserted at any time?
Class question: how to ensure that line table storage can be inserted at any time?
2022-06-11 18:03:00 【Hold on to the idea and cut the river】
Today, the teacher's data structure class , I asked this question in class , When a linear table is stored sequentially , How to ensure that it can be inserted at any time ? The sequence table insertion code is as follows :
Status ListInsert_Sq(Sqlist &L,int i,ElemType e){
if(i<1 || i>Length+1) return ERROR;
if(L.Length >= MAXSIZE) return ERROR;
for(int j= L.length-1;j>=i-1;j--)
L.elem[j+1]= L.elem[j];
++L.length;
return OK;
}
Problem solving
Divided into two steps , Mainly aimed at ERROR To resolve the errors that have occurred
1、ERROR1:i<1 || i> Length+1
If i<1 Then let him i = 1
If i>Length + 1 Then let him Length+1
2、ERROR2:L.length>=MAXSIZE
Use this time c Linguistic realloc, This function is to grow the array on its original basis .malloc And c++ Of new You need to rewind the array , therefore realloc better .
边栏推荐
- 社会工程学实战入门
- 6-3 reading articles (*)
- Intelligent overall legend, legend of wiring, security, radio conference, television, building, fire protection and electrical diagram [transferred from wechat official account weak current classroom]
- Why is the UDP stream set to 1316 bytes
- Service learning notes 03 front desk service practice
- Tidb CDC create task error unknown or incorrect time zone
- Hwang
- 7-1 are prime numbers
- 6-7 file read / write operation
- tidb-ddl的速度的调整
猜你喜欢
![Acwing game 40 [End]](/img/6b/a9ea5e1f9578d21219c69571e8b0f8.jpg)
Acwing game 40 [End]
![Spring 2021 daily question [week7 not finished]](/img/93/582608e18bf6d78c552fa9478cdd77.jpg)
Spring 2021 daily question [week7 not finished]

vulhub

Tle6389-2g V50's unique pwm/pfm control scheme has a duty cycle of up to 100%, forming a very low differential pressure - keshijin mall

mysql8安装,navicat安装,sqli-labs搭建

Why is the UDP stream set to 1316 bytes

MFSR:一种新的推荐系统多级模糊相似度量
![Codeworks round 481 (Div. 3) [done]](/img/60/01ed6180ccc4c99fe361d493525018.jpg)
Codeworks round 481 (Div. 3) [done]

【先收藏,早晚用得到】100个Flink高频面试题系列(二)
![Winter vacation daily question 2022 [week1 not finished]](/img/56/a5ca98ddd128bcceb8e24f0edfeac6.jpg)
Winter vacation daily question 2022 [week1 not finished]
随机推荐
Tidb CDC log tables are not eligible to replicate
Hello go (XIII). Go language common standard library III
tidb-cdc日志tables are not eligible to replicate
【先收藏,早晚用得到】49个Flink高频面试题系列(一)
vulhub
R language to find missing value location of data set
[collect first and use it sooner or later] 49 Flink high-frequency interview questions series (I)
Simple understanding of events
Sqli labs customs clearance hey hey~
Intelligent overall legend, legend of wiring, security, radio conference, television, building, fire protection and electrical diagram [transferred from wechat official account weak current classroom]
Mathematical foundations of information security Chapter 3 - finite fields (I)
Codeworks round 479 (Div. 3) [done]
Service学习笔记04- 其他服务实现方式与替代方式
Service learning notes 02- actual combat startservice and bindservice
zabbix怎样自定义mysql监控项并触发告警
网络安全威胁情报体系
The maximum (minimum, latest and top n) records are taken for MySQL grouping
Difference between require and ES6 import
About element location and size
System learning typescript (V) - joint type