线性表的合并
7-1 线性表的合并 (40 分)
求解一般集合的并集问题。 已知两个集合A和B,现要求一个新的集合A=AUB。例如,设 A=(7,5,3,11) B=(2,6,3) 合并后 A=(7,5,3,11,2,6)
#include <iostream>
#include <cstdlib>
using namespace std;
#define MaxSize 100
typedef int ElemType;
typedef struct
{
ElemType data[MaxSize];
int length;
} SqList;
void InitList(SqList *&L)
{
L=(SqList *)malloc(sizeof(SqList));
L->length=0;
}
int LocateElem(SqList *L,ElemType e)
{
int i=0;
while(i<L->length&&L->data[i]!=e)
i++