33,311
社区成员
发帖
与我相关
我的任务
分享
typedef struct SqList
{
ElemType *elem; // 存储空间基址
int length; // 当前长度
int listsize; // 当前分配的存储容量(以sizeof(ElemType)为单位)
}*SqList;
int main(int argc, char *argv[])
{
SqList mylist;
InitList(mylist);
return 0;
}
Status InitList(SqList L)
{ // 操作结果:构造一个空的顺序线性表---------------1
L->elem=(ElemType*)malloc(LIST_INIT_SIZE*sizeof(ElemType));//运行到这里就出错
L->length=0; // 空表长度为0
L->listsize=LIST_INIT_SIZE; // 初始存储容量
return OK;
}
typedef struct SqList
{
ElemType *elem; // 存储空间基址
int length; // 当前长度
int listsize; // 当前分配的存储容量(以sizeof(ElemType)为单位)
}*SqList;
#define LIST_INIT_SIZE 10
typedef int ElemType;
typedef struct SqList
{
ElemType *elem; // 存储空间基址
int length; // 当前长度
int listsize; // 当前分配的存储容量(以sizeof(ElemType)为单位)
}*Sqist;
int InitList(Sqist L)
{ // 操作结果:构造一个空的顺序线性表---------------1
L->elem=(ElemType*)malloc(LIST_INIT_SIZE*sizeof(ElemType));//运行到这里就出错
L->length=0; // 空表长度为0
L->listsize=LIST_INIT_SIZE; // 初始存储容量
return 1;
}
int main(int argc, char *argv[])
{
SqList mylist;
InitList(&mylist);
return 0;
}
typedef struct SqList_l //最好别同名
{
ElemType *elem; // 存储空间基址
int length; // 当前长度
int listsize; // 当前分配的存储容量(以sizeof(ElemType)为单位)
}*SqList;
int main(int argc, char *argv[])
{
SqList mylist;
mylist=(SqList_l *)malloc(sizeof(SqList_l); //给指针分配空间
InitList(mylist);
return 0;
}
Status InitList(SqList &L) //最好传引用
{ // 操作结果:构造一个空的顺序线性表---------------1
L->elem=(ElemType*)malloc(LIST_INIT_SIZE*sizeof(ElemType));//运行到这里就出错
L->length=0; // 空表长度为0
L->listsize=LIST_INIT_SIZE; // 初始存储容量
return OK;
}