|
[PHP]List Insert_List(List L)
{
int i;
ElemType value;
ElemType *newbase,*q,*p;
printf("lease Input The Insert Number And Value: ");
while(2 != scanf("%d%d",&i,&value)) continue;
if(i<1 || i>L.length+1) exit(1);
if(L.length>=L.listsize){
newbase=(ElemType *) realloc(L.elem,
(L.listsize+LISTINCREMENT) * sizeof(ElemType));
if (!newbase) exit(1);
L.elem=newbase;
L.listsize+=LISTINCREMENT;
}
q=&(L.elem[i-1]);
for (p=&(L.elem[L.length-1]);p>=q; --p)
*(p+1) = *p;
*q = value;
++L.length;
printf("The Value %d Had Insert\n",value);
printf("The List Value:\n");
while(getchar()) continue;
Display_List(L);
return L;
}
[/PHP]
我一输入两个整数,就会结束程序,不知道为什么! ElemType 为 int 型! |
|