#include <stdio.h>
#include<stdlib.h>
//实现两个线性表的并集
//function result status code
#define TURE 1
#define FALSE 0
#define OK 1 //很多函数的返回类型是Status(是用typrdef定义的intl类型),这种类型返回turn\false或ok\error
#define ERROR 0
#define INFEASAIBE -1 //infeasible 不可行 eg:求后继元素时,如果是最后一个元素,求其后继不可行,就会return infeasible
#define OVERFLOW -2 //一般用于exit的参数中,eg:创建指针时,一般判断内存是否分配成功,不成功一般调用return exit(overflow)
typedef int Status;
typedef struct{
int* data;
int length;
}List;
Status InitList(List& L);
Status ListLength(List& L);
Status compare(int a,int b);
Status GetElem(List& L,int i,int& e);
Status LocateElem(List L,int e,Status(*compare)(int ,int ));
Status ListInsert(List& L,int i,int e);
Union(List& La,List Lb);
void output(List& L);
Status InitList(List& L){
L.data = (int*)malloc(30 * sizeof(int));
if(!L.data ) exit(OVERFLOW);
L.length=0;
return OK;
}
Status ListLength(List& L
[数据结构练习01]两个线性表La、Lb表示两个集合,求A=AUB
最新推荐文章于 2024-07-12 01:14:17 发布
[数据结构练习01]两个线性表La、Lb表示两个集合,求A=AUB
摘要由CSDN通过智能技术生成