<span style="font-family: Arial, Helvetica, sans-serif;">#include<stdio.h></span>
#include <conio.h>
#include<stdlib.h>
#include<iostream.h>
#define MAXSIZE 100
typedef int ElemType;
typedef struct
{
ElemType *elem;
int length;
}SqList;
SqList LA,LB;
void InitList(SqList &LA,SqList &LB)
{
LA.elem = new ElemType[MAXSIZE];
LB.elem = new ElemType[MAXSIZE];
if((!LA.elem)||(!LB.elem))
{
cerr<<"存储分配错误!"<<endl;
exit(1);
}
LA.length=0;
LB.length=0;
}
int Length(SqList &L)
{
return L.length;
}
int Search(SqList &L,ElemType x)
{
for (int i=1;i<=L.length;i++)
if(L.elem[i-1]==x) return i;
else return 0;
}
bool Insert(SqList &L,int i,ElemType &x)
{
if(L.length==MAXSIZE) return false;
if(i<0||i>L.length+1) return false;
for(int j=L.length;j>=i;j--)
L.elem[j]=L.elem[j-1];
L.elem[i-1]=x;
L.length++;
return true;
}
void Merge(SqList &LA,SqList &LB)
{/*合并线性表LA与LB,结果存于LA,重复元素只留一个*/
int n = Length(LA),m = Length(LB);
int i,k,x;
for (i=1;i<=m;i++)
{
x=LB.elem[i-1];
k=Search(LA,x);
if(k==0)
{
Insert(LA,n+1,x);
n++;
}
}
}
void main()
{
SqList LA,LB;
/*for(int i=1;i<=MAXSIZE;i++)
{
scanf("%d", &LA.elem[i-1]);
getchar();
for(int j=1;j<=MAXSIZE;j++)
{
scanf("%d", &LB.elem[j-1]);
getchar(); */
/*printf("请输入要插入的数据,以0结束!\n");
ElemType elem;
scanf("%d",LA.elem);
while(elem!=00)
{
Insert(LA,1,elem);
scanf("%d",LA.elem);
};
scanf("%d",LB.elem);
while(elem!=00)
{
Insert(LB,1,elem);
scanf("%d",LB.elem);
}
Merge(LA,LB);
cout<<LA.elem<<endl;
}*/
LA.elem[1]=7;
LA.elem[2]=5;
LA.elem[3]=3;
LA.elem[4]=11;
LB.elem[1]=2;
LB.elem[2]=6;
LB.elem[3]=3;
Merge(LA,LB);
for(int k=0;k<=6;k++)
printf("%d",LA.elem[k]);
}