怎么改我也改不对.....
#include<stdio.h>#include<stdlib.h>
#include<malloc.h>
#define OVERFLOW -2
#define OK 1
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
typedef struct
{
int *elem;
int length;
int listsize;
}SqList;
InitList_Sq(SqList &L,int n)
{
L.elem=(int* )malloc(LIST_INIT_SIZE*sizeof(int));
if(!L.elem)exit(OVERFLOW);
L.length=n;
L.listsize=LIST_INIT_SIZE;
int i=1;
for(i=1;i<L.length;i++)scanf("%d ",&L.elem[i]);
return OK;
}
int Load_Sq(SqList&L)
{int i=1;
for(i=1;i<L.length+1;i++)printf("%d ",L.elem[i]);
printf("\n");
return OK;
}
void main()
{
SqList T;
int n;
scanf("%d",&n);
if(InitList_Sq(T,n))
{printf("The List is:");
Load_Sq(T);
}
}
问题是最后一个L.elem[5]不对