数据结构 线性表 顺序表示和实现

predefine.h//预定义函数返回结果头文件//文件名pre_define.h//函数结果状态代码#define TRUE 1#define FALSE 0#define OK 1#define ERROR 0#define INFEASIBLE -1#define OVERFLOW -2#define UNDERFLOW -2//假设数组维数的最大值为8#d
摘要由CSDN通过智能技术生成

predefine.h

//预定义函数返回结果头文件
//文件名pre_define.h
//函数结果状态代码
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2
#define UNDERFLOW -2

//假设数组维数的最大值为8
#define MAX_ARRAY_SIZE 8

//Status是函数的类型,其值是函数结果状态代码
typedef int Status;

//Boolean是布尔类型,其值是TRUE或FALSE
typedef int ElemType;

SqList.cpp

<pre name="code" class="cpp"#include "pre_define.h"#include <stdio.h>#include <stdlib.h>#include <malloc.h>#define LIST_INIT_SIZE 100 // 线性表存储空间的初始分配量#define LISTINCREMENT 10 // 线性表存储空间的分配增量typedef struct{ElemType *elem; // 存储空间基址int length; // 当前长度int listsize; // 当前分配的存储容量} SqList;bool compare(ElemType e1, ElemType e2){if (e1 == e2)return true;return false;}Status InitList_Sq(SqList &L){// 构造一个空的线性表LL.elem = (ElemType *)malloc
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值