作业帮 > 综合 > 作业

#define TURE 1 #define FALSE 0 #define OK 1 #define ERROR 0

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/12 07:55:36
#define TURE 1 #define FALSE 0 #define OK 1 #define ERROR 0 #define INFEASIBLE -1 #define OVERFLOW
#define TURE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2
typedef int status;
typedef int ElemType;
#include
#define LIST_INIT_SIZE 100//线性表存储空间的初始分配值
#define LISTINCREMENT 10//线性表存储空间的分配增量
typedef struct{
ElemType *elem;
int length;
int listsize;
}SqList;
status InitList_Sq(SqList &L)
{//构造一个空的线性表L
L.elem=(ElemType * )malloc(LIST_INIT_SIZE * sizeof(ElemType));
if(!L.elem) exit(OVERFLOW);//存储分配失败
L.length=0;//空表长度为0
L.listsize=LIST_INIT_SIZE;//初始存储容量
return OK;
}//InitList-Sq
ElemType * newbase,* q,* p;
status ListInsert_Sq(SqList &L,int i,ElemType e)
{
//在顺序线性表L中第i个位置之前插入新的元素e,
//i的合法值为1=q;p--)
*(p+1)=*p;//插入位置及以后的元素右移
*q=e;//插入e
++L.length;//表长增1
return OK;
}//ListInsert_sq
为什么编译不能通过?确切的说线性表插入编译通不过!
status ListInsert_Sq(SqList &L,int i,ElemType e)
{
//在顺序线性表L中第i个位置之前插入新的元素e,
//i的合法值为1=q;p--) /*~大写p改成小写~*/
*(p+1)=*p;//插入位置及以后的元素右移
*q=e;//插入e
++L.length;//表长增1
return OK;
}//ListInsert_sq