*elem;
int length;
int listsize;
} Sqlist;
status Create_sq(Sqlist *L,int n)
{
int i;
L->elem=(int*)malloc(100*sizeof(int));
if(!L->elem) return 0;
for(i=0;i
scanf("%d",&(L->elem[i]));
L->length=n;
L->listsize=100;
return 1;
}
status Listinsert_sq(Sqlist *L,int i,int e)
{
int *q,*p,*newbase;
if(i<1||i>L->length+1) return 0;
if(L->length>=L->listsize)
{
newbase=(int*)realloc(L->elem,(L->listsize+10)*sizeof(int));
if(!newbase) exit(-2);
L->elem=newbase;
L->listsize+=10;
}
q=&(L->elem[i-1]);
for(p=&(L->elem[L->length-1]);p>=q;--p)
*(p+1)=*p;
*q=e;
++L->length;
return 1;
}
int main()
{
Sqlist L1;
int n,a;
int i,e;
printf("n please input the number of data:n");
scanf("%d",&n);
if(Create_sq(&L1,n)==1)
{
scanf("%d%d",&i,&e);
a=Listinsert_sq(&L1,i,e);
if(a==1)
printf("insert successn");
else printf("insert falsen");
printf("the list elements are:n");
for(i=1;i<=L1.length;i++)
{
printf("%dt",L1.elem[i-1]);
}
}
return 0;
}