#include <stdio.h>
#define MAXSIZE 100
#define OK 1
#define ERROR 0
typedef struct{
int *elem;
int length;
}Sqlist;
int InitList(Sqlist &L);
int ListInsert(Sqlist &L,int i,int e);
int InitList(Sqlist &L){
L.elem=new int[MAXSIZE];
L.length=0;
return OK;
}
int ListInsert(Sqlist &L,int i,int e){
if((i<1)||(i>L.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.elem[i-1]=e;
++L.length;
return 0;
}
int main(){
Sqlist L;
InitList(L);
ListInsert(L,1,5);
ListInsert(L,2,4);
ListInsert(L,3,6);
ListInsert(L,2,100);
for(int i=0;i<L.length;i++)
{
printf("%d ",L.elem[i]);
}
return 0;
}
10-02
4719
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)