c语言代码 实现两张顺序表归并
将两张顺序表La,Lb,归并入表Lc
#include<stdio.h>
#include<stdlib.h>
#define LIST_INIT_SIZE 100 //存储空间初始分配量
#define LISTINCREMENT 10 //存储空间分配增值
typedef int ElemType;
typedef struct
{
ElemType *elem; //存储空间基址
int length; //当前长度
int listsize; //当前分配的存储空间
} SqList;
/*建立一个空的有序表*/
SqList InitList_Sq()
{
SqList L;
L.elem=(ElemType*)malloc(LIST_INIT_SIZE*sizeof(ElemType)); //分配空间
if (!L.elem)
{
printf("分配空间失败!\n");
exit(0);
}
L.length=0; //将当前线性表长度置0
L.listsize= LIST_INIT_SIZE;
return L; //成功返回OK
}
/*在有序表L的第i个元素之前插入一个元素(其值为e)*/
SqList ListInsert_Sq(SqList L,int i,ElemType e)
{
ElemType *newbase,*p,*q;
if(i<1||i