定义线性表结构体(数组)
#include <stdio.h>
#include <stdlib.h>
typedef int bool;
#define true 1
#define false 0
#define LIST_INIT_SIZE 100 //线性表存储空间的初始分配量
#define LISTINCREMENT 10 //线性表存储空间的分配增量
typedef int ElemType ;
typedef struct {
ElemType *elem; //数组指针,指示线性表的基地址
int length; //当前长度
int listsize; //当前分配的存储容量(以sizeof(ElemType)为单位)
} SqList,*SqListPtr;
创建
bool InitList(SqList L){
L.elem=(ElemType *)malloc(LIST_INIT_SIZE*sizeof(ElemType));
if(!L.elem){
return false;
}
L.length=0;
L.listsize=LIST_INIT_SIZE;
return true;
}
按位置查找
ElemType* List_Retrival(SqListPtr L,int pos,ElemType* elem){

最低0.47元/天 解锁文章
1061

被折叠的 条评论
为什么被折叠?



