下面的这个程序不是很完整的,因为集合c没有删除ab中相同的数,还有下面的这个程序你要建在文件里才没有错误,建源文件时,要表明是。c文件,在运行时,你要注意输入的方式,如果你有问题再问好了
#include
#include
#define MAX 256
//typedef int List[MAX];
typedef int ElemType;
typedef int Status;
#define OVERFLOW -1
#define OK 1
#define LIST_INIT_SIZE 80
#define LISTINCREMENT 10
typedef struct {
ElemType *elem;
int length;
int listsize;
} SqList;
typedef SqList List;
Status InitList_Sq( SqList* L )
{
(*L)。
elem = (ElemType*) malloc (LIST_INIT_SIZE*sizeof (ElemType));
if (!(*L)。elem) exit (OVERFLOW);
(*L)。
length = 0;
(*L)。listsize = LIST_INIT_SIZE;
return OK;
}
void main()
{
int ListLength(List Lx);
void GetElem(List Lx,int i,ElemType *xi);
Status InitList_Sq( SqList* L );
void ListInsert(List *Lc,int k,ElemType e);
void MergeList(List La,List Lb);
void printElem(List Lx);
List La,Lb;
int i;
InitList_Sq(&La );
InitList_Sq(&Lb );
printf("pls input length of La ,Lb
");
scanf("%d,%d",&La。
length,&Lb。length);
printf("intiating La。。。。
");
for(i=1;i0 && i<=Lx。length) *xi=Lx。elem[i];
// printf("current value get: %d
",Lx[i]);
// printf("current value get: %d
",xi[i]);
}
int ListLength(List Lx)
{
return Lx。
length;//
}
void ListInsert(List *Lc,int k,ElemType e)
{
(*Lc)。elem[k]=e; //printf("insert success to e=%d
",e);
}。
全部