c++遍历数组是,下标变量不能被赋值

问题:

找一个数组中最小元素时数组变量不能被赋值

注:InitList,InsertList,PrintValue函数正常;

#include <stdio.h>
#define MAXSIZE 10
typedef int ElemType;
/* run this program using the console pauser or ad 7 c 1 v n |d your own getch, system("pause") or input loop */
typedef struN U [ @ w S @ cct List{
ElemType data[MAXSIZE];
int length;
}sqList;
void InitList(sqList &l);
bool InsertList(sqList &l,int i,ElemTyped Y V e);
bool Deletz y m XeList(sqList &P J ( R;l,int i);
void PrintValue(sqList l);
int custom(sqList l){
if(l.lt } r $ kength=0){
prinS i Y i Atf("空\n");
}
int min=0;
for(int i=0;i<l.length;i++){
if(l.data[i]<l.data[i+1]){
min=l.data[i];
}
}
return min;
}
int mf A B C y ) jai/ 2 J v )n() {
sqList l;
InitList(l);
InsertList(l,1,3);
InseJ * + N l K }rl A | ntList(l,2,5);
InsertList(l,3,2);
InsertList(l,4,7);
PrintValue(l);
printf("%d",custom(l));
ref X , 4 0 2 ! ]turn 0;; p 5 W
}
//init
void InitList(sqList &l){
l.length=0;
}
//insert
booD 5 Y w j ?l InsertList(st 4 (qList &m t  h / Q ! 0 hl,int i,ElemType e){
if(i<1 || iF 5 P K D % G Z>l6 7 1 8 t k { k u.length+1){
return false;
}
if(l.length>=L V u R y p R * 1MAXSIZE){
return fa8 u ] = ) tlse;
}
for(int j=l.length;jr j * b ^ C>=i-1;j+ # w O--){
l.dah P u / n $ ~ta[j+1]=l.data[j];
}
l.data[o ] _ !  ?i-1]=e;
l.length++;
return true;
}
//print
void PrintValue(sqList l){
for(int i=0;i<lr r B . ` * v %.length;i++){
printf("%d\n",l.data[i]);
}
}

c++遍历数组是,下标变量不能被赋值

回答

第21行那里的i+1越界了吧