#include<stdio.h>
#include<malloc.h>
#define SIZE 10
typedef struct list{
int*elem;
int length;
int size;
}List;
List InitList()
{
List t;
t.elem=(int*)malloc(SIZE*sizeof(int));
if(!t.elem)
{
printf("初始化失败!");
}
else
{
t.length=0;
t.size=SIZE;
}
return t;
}
List ListInsert(List L,int i, int e)
{
int j;
if(i<1||i>L.length+1)
{
printf("插入位置错误!");
}
for(j=L.length;j>=i-1;j--)
{
L.elem[j+1]=L.elem[j];
}
L.elem[i-1]=e;
L.length++;
return L;
}
void MergeList(List*LA,List*LB)
{
int i,j,m,n;
for(i=0;i<(*LA).length;i++)
{
for(j=0;j<(*LB).length;j++)
{
n=(*LA).length;
m=(*LB).elem[i];
if((*LB).elem[i]==(*LA).elem[j])
continue;
else
{
ListInsert(*LA,++n,m);
}
}
}
}
void main()
{
List LA=InitList();
List LB=InitList();
int i,j;
printf("请输入第一个表元素的个数:\n");
scanf("%d",&LA.length);
printf("请输入第二个表元素的个数:\n");
scanf("%d",&LB.length);
printf("请输
线性表合并
最新推荐文章于 2021-04-10 16:56:42 发布