目录
线性表
线性表 (Linear List) 是n个具有相同特性的数据元素的有限序列。
基本操作
上面的是C下面的是C++
所需头文件及预定义
#include<stdlib.h>
#include<stdio.h>
#define MaxSize 100
#define ok 1
#define error 0
#define overflow -2
typedef int Status;
typedef struct{
int data[MaxSize];
int length;
}SqList;
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define MaxSize 100
#define ok 1
#define error 0
#define overflow -2
typedef int Status;
typedef int ElemType;
typedef struct{
ElemType data[MaxSize];
int length;
}SqList;
初始化
//初始化操作,建立一个空的线性表L
Status InitList_Sq(SqList &L){
if(!L.data)
exit(overflow);
L.length = 0;
return ok;
}
int main(){
SqList L;
InitList_Sq(L);
}
建表
//建表
void CreastList(SqList &L,int n)