帮忙运行一段代码求并集的顺序表实现
#include<stdio.h>#include<malloc.h>
#define bool int
#define false 0
#define true 1
#define MAXSIZE 10
typedef int ElemType;
typedef struct
{
ElemType node[MAXSIZE];
int length;
}SqList;
int InsertList(SqList *L,int i,int e)
{
int j;
if( i<0 || i>L->length)
return -1;
for(j=i;j<L->length-1;j--)
{
L->node[j+1]=L->node[j];
}
L->node[i]=e;
return 0;
}
bool GetElem(SqList *L,int i,ElemType *e)
{
if(i<0 || i>L->length)
return false;
* e=L->node[i];
return true;
}
int locateElem(SqList *L,int e)
{
int i=0;
while( i && L->node[i]!=e )
{
i++;
}
if(L->node[i]=e)
return 1;
return 0;
}
int LengthSqList(SqList *L)
{
int i;
int len;
while(L->node[i])
{
i++;
len++;
}
return len;
}
void InitList(SqList *L)
{
int i;
L=(SqList *)malloc(sizeof(SqList));
for (i=0;i<MAXSIZE;i++)
L->node [i]=(ElemType )malloc (sizeof (ElemType ));
}
int unionList(SqList *L1,SqList *L2)
{
int i;
int len1,len2;
SqList *L3=NULL;
ElemType *e;
len1=LengthSqList(L1);
len2=LengthSqList(L2);
InitList(L3);
for(i=0;i<len1;i++)
{
if(GetElem(L1,i,*e))
InsertList(L3,i,e);
}
for(i=0;i<len2;i++)
{
if(GetElem(L2,i,e))
{
if( locateElem(L1,*e))
InsertList(L3,i,e);
}
}
printf("“C");
while(L3->node[i])
{
printf("%d",L3->node[i]);
i++;
}
}
int main()
{
SqList *L11=NULL,*L22=NULL;
int i;
InitList(L11);
InitList(L22);
printf("A");
for(i=0;i<MAXSIZE;i++)
{
scanf("%d",&L11->node[i]);
}
printf("B");
for(i=0;i<MAXSIZE;i++)
{
scanf("%d",&L22->node[i]);
}
unionList(L11,L22);
return 0;
}
没有错误但是输入顺序表 A就停止了为什么