#include<stdio.h>
#include <stdlib.h>
#define MaxSize 10
typedef float ElemType;//重命名
typedef struct {
ElemType *p;
int length;
}List;
int InitList(List& L);
int main() {
List *L1, *L2;
int i;
L1->p = (ElemType*)malloc(sizeof(ElemType) * MaxSize);//动态分配空间
L2->p = (ElemType*)malloc(sizeof(ElemType) * MaxSize);
InitList(*L1);
InitList(*L2);
for (i = 0; i < L1->length; i++) { //通过遍历改变表的值
scanf("%f\n",&L1->p[i]);
printf("表L1的元素为:%f\n",L1->p[i]);
}
for (i = 0; i < L2->length; i++) {
scanf("%f\n", &L2->p[i]);
printf("表L1的元素为:%f\n", L2->p[i]);
}
return 0;
}
int InitList(List& L) {
if (!L.p)
return 0;
L.length = MaxSize;
return 1;
}
报错如图:
晕 l1和l2都没实体化