C语言线性表基本操作

时间:2013-05-23 06:00:54
【文件属性】:
文件名称:C语言线性表基本操作
文件大小:16KB
文件格式:DOCX
更新时间:2013-05-23 06:00:54
C 线性表 基本操作 纯C语言写的线性表基本操作 程序段:/*线性表的操作*/ #include #include typedef int ElemType; struct List { ElemType *list; int size; int MaxSize; }; /*初始化列表,即动态存储空间分配并置L为一个空列表*/ void initList(struct List *L,int ms) { if(ms<=0) { printf("MaxSize 非法!"); exit(1); } L->MaxSize = ms; L->size = 0; L->list=malloc(ms * sizeof(ElemType)); if(!L->list) { printf("空间分配失败!"); exit(1); } /*printf("%d\n",sizeof(ElemType));*//*暂用字节数*/ return ; }

网友评论

  • 还可以 对具体的实例有指导作用