一个程序问题,帮我改一下错误,可以的话帮我再备注一下错误在哪,谢谢!
#include<iostream>#define [MaxSize] 50;
using namespace std;
typedef struct
{ int data[MaxSize];
int length;
}SqList;
void InitList(SqList*&L)
{ L=(SqList*)malloc(sizeof(SqList));
L->length=0;
}
void DestroyList(SqList*&L)
{ free (L);
}
bool ListEmpty(SqList*)
{ return(L->length==0);
}
int ListLength(SqList*L)
{ return(L->length);
}
void DispList(SqList*L)
{ for(int i=0;i<L->length;i++)
cout<<"%d"<<L->data[i];
cout<<endl;
}
bool GetElem(SqList*L,int i,ElemType & e)
{ if(i<1||i>L->length)
return false;
e=L->data[i-1];
return true;
}
int LocateElem(SqList*L,ElemType e)
{ int i=0;
while(i<L->length && L->data[i]!=e)
i++;
if(i>=L->length)
return 0;
else return (i+1;
}
bool ListInsert(SqList*&L,int i,ElemType e)
{ int j;
if(i<1||i>L->length+1)
return false;
i--;
for(j=L->length;j>i;j--)
L->data[j]=L->data[j-1];
L->data[i]=e;
L->length++;
return true;
}
bool ListDelete(SqList*&L,int i,ElemType & e)
{ int j;
if(i<1||i>L->length)
return false;
i--;
e=L->data[i];
for(j=i;j<L->length-1;j++)
L->data[j]=L->data[j+1];
L->length--;
return true;
}
int main()
{ int i=0,j=0,L;
void InitList(SqList*&L);
void DestroyList(SqList*&L);
bool ListEmpty(SqList*);
int ListLength(SqList*L);
void DispList(SqList*L);
bool GetElem(SqList*L,int i,ElemType&e);
int LocateElem(SqList*L,ElemType e);
bool ListInsert(SqList*&L,int,ElemType e);
bool ListDelete(SqList*&L,int i,ElemType & e);
}