#include<iostream>
using namespace std;
#define TRUE 1
#define FALSE 0
#define ok 1
#define error 0
#define OVERFLOW -2
typedef int Status;
typedef int ElemType;
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
typedef struct { //结构体(顺序表的)
ElemType *elem;
int length;
int listsize;
}SqList;
SqList Lx;
Status InitList_Sq(SqList &L) //分配空间
{ L.elem=new ElemType[LIST_INIT_SIZE];
if(!L.elem)exit(OVERFLOW);
L.length =0;
L.listsize=LIST_INIT_SIZE;
return ok;
}
Status ListInsert(SqList &L,int i,ElemType e) //插入新元素
{ int *q,*p;ElemType *newbase;
if(i<1 || i>L.length+1) return error;
if(L.length>=L.listsize)
{ newbase=new ElemType[L.listsize+LISTINCREMENT];
if(!newbase) exit(OVERFLOW);
L.elem=newbase;
L.listsize+=LISTINCREMENT;
}
q=&(L.elem[i-1]);
for (p=&(L.elem[L.length-1]);p>=q;--p)
*(p+1)=*p;
*q=e;
++L.length;
return ok;
}
Status Listlength(SqList L) //长度
{ int *p=L.elem; //判断线形表是否存在
while(p)
{ return (L.length); }
}
Status GetElem(SqList L, int i,ElemType &e) //取元素
{ if(i<1 || i>L.length)
return error;
else
{ e=L.elem[i-1];
return e;
}
}
void MergeList(SqList La,SqList Lb,SqList &Lc) //合并
{ ElemType ai,bj;
InitList_Sq(Lc);
int i=1,j=1,k=0;
int La_len,Lb_len;
La_len=Listlength(La);
Lb_len=Listlength(Lb);