数据结构 c语言 各位大虾帮忙看看那

来源:百度知道 编辑:UC知道 时间:2024/05/22 12:18:44
#include "headfile.h"
#include "malloc.h"
#include "stdlib.h"
Status ListInsert_Sq(SqList &L, int i,ElemType e){
//在顺序线性表L中第i个位置之前插入新的元素e
//i的合法值为1≤i≤ListLength_Sq(L)+1
int p;
int q;
int newbase;
if(i<1 || i>L.length+1)return ERROR; //i值不合法
if(L.length>=L.listsize){ //当前存储空间已满,增加分配
newbase = (ElemType *)realloc(L.elem,
(L.listsize+LISTINCREMENT)*sizeof(ElemType));
if(!newbase)exit(OVERFLOW); //存储分配失败
L.elem = newbase; //新基址
L.listsize += LISTINCREMENT; //增加存储容量
}
q = & (L.elem[i-1]); //q为插入位置
for (p = &(L.elem[L.length-1]); p>=q; --p)*(p+1)=*p;//插入位置及之后的元素右移
* q=e; //插入e
++L.length; //表长增1
return OK;
}//ListInsert_Sq

--------------------Configuration: test - Win32 Debug--------------------
Compiling...
ListInsert.cpp
d:\dd\test\listinsert.cpp(13) : error C2440:

没有你的头文件,没法帮你调,目前看到的几处错误
#include "malloc.h"
#include "stdlib.h"
这两个是头文件要用<>而不是" "
还有类似这样的赋值L.elem = newbase数据类型不匹配