主题:语法错误turboc2.0
#define N 10
typedef struct ListItem{
int num;
}ListItem;
typedef struct alist *List;
typedef struct alist{
int n;
int maxsize;
ListItem *table;
}Alist;
[color=FF0000]List ListInit(int size){
List L=(List)malloc(sizeof *L);
L->table=(ListItem *)malloc(size*sizeof(ListItem));
L->maxsize=size;
L->n=0;
return L;[/color]}
void inPutList(List L){
int i;
for (i=0;i<L->n;i++) scanf("%d",&L->table[i].num);
}
void PrintList(List L){
int i;
for (i=0;i<L->n;i++) printf("%d\n",L->table[i].num);
}
void ReverseList(List L){
ListItem tmp;
int i;
for (i=0;i<L->n/2;i++) {
tmp=L->table[i];
L->table[i]=L->table[L->n-1-i];
L->table[L->n-1-i]=tmp;
}
}
int main(){
List L=ListInit(N);
L->n=6;
printf("please input:\n");
inPutList(L);
printf("Reverse output:\n");
ReverseList(L);
PrintList(L);
return 0;
}
红的地方编译时有语法错误,
帮我看看
typedef struct ListItem{
int num;
}ListItem;
typedef struct alist *List;
typedef struct alist{
int n;
int maxsize;
ListItem *table;
}Alist;
[color=FF0000]List ListInit(int size){
List L=(List)malloc(sizeof *L);
L->table=(ListItem *)malloc(size*sizeof(ListItem));
L->maxsize=size;
L->n=0;
return L;[/color]}
void inPutList(List L){
int i;
for (i=0;i<L->n;i++) scanf("%d",&L->table[i].num);
}
void PrintList(List L){
int i;
for (i=0;i<L->n;i++) printf("%d\n",L->table[i].num);
}
void ReverseList(List L){
ListItem tmp;
int i;
for (i=0;i<L->n/2;i++) {
tmp=L->table[i];
L->table[i]=L->table[L->n-1-i];
L->table[L->n-1-i]=tmp;
}
}
int main(){
List L=ListInit(N);
L->n=6;
printf("please input:\n");
inPutList(L);
printf("Reverse output:\n");
ReverseList(L);
PrintList(L);
return 0;
}
红的地方编译时有语法错误,
帮我看看