顺序表的合并(纯小白)
#include "stdio.h"#include "malloc.h"
#define OK 1
#define OVERFLOW -1
#define ERROR 0
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
typedef int ElemType;
typedef int Status;
typedef struct{
ElemType *elem;
int length;
int listsize;
}sqlist;
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 MergeList_Sq(SqList La,SqList Lb,SqList &Lc){
pa=La.elam;pb=Lb.elem;
Lc.listsize=Lc.length=La.length+Lb.length;
pc=Lc.elem=(ElemType *)malloc(Lc.listsize*sizeof(ElemType));
if(!Lc.elem)exit(OVERFLOW);
pa_last=La.elem+La.length-1;
pb_last=Lb.elem+Lb.length-1;
while(pa<=pa_last&&pb<=pb_last){
if(*pa<=*pb)*pc++=pa++;
else*pc++=*pb++;
}
while(pa<=pa_last)*pc++=*pb++;
while(pb<=pb_last)*pc++=*pb++;
}
这些都是算法?还需要一个主程序?然后再怎么弄、呃、就学C语言的时候敲过三两个程序、真心不懂、求指教、帮忙写完、谢谢、