请各位帮忙纠错 有关MergeList
#include <math.h>#include <stdio.h>
#include <stdlib.h>
#define OK 1
#define ERROR 0
#define OVERFLOW -2
#define LIST_INIT_SIZE 10
#define LISTINCREMENT 10
#define NUM 10
typedef struct LNode{
int data;
struct LNode *next;
}LNode,*LinkList;
/*P28*/
LinkList La;LinkList Lb;LinkList Lc;int e;
/*全局*/
void GreatList_La(int n){
LNode *p;LinkList L;int i;
L=(LinkList)malloc(sizeof(LNode));
L->next=NULL;
for(i=n;i>0;--i){
p=(LinkList)malloc(sizeof(LNode));
scanf("%d",&p->data);
p->next=L->next;L->next=p;
}
}
void GreatList_Lb(int n){
LNode *p;LinkList L;int i;
L=(LinkList)malloc(sizeof(LNode));
L->next=NULL;
for(i=n;i>0;--i){
p=(LinkList)malloc(sizeof(LNode));
scanf("%d",&p->data);
p->next=L->next;L->next=p;
}
}
void MergeList_L(){
LNode *next,*h,*pa,*pb,*pc; int k;
pa=La->next;pb=Lb->next;
Lc=pc=La;
while(pa&&pb){
if(pa->data<=pb->data){
pc->next=pa;pc=pa;pa=pa->next;
}
else{pc->next=pb;pc=pb;pb=pb->next;}
}
pc->next=pa?pa:pb;
free(Lb);
h=Lc->next;
printf("new list:\n");
for(k=0;k<20;k++){
printf("%3d",h->data);
h=h->next;
}
}
void main()
{
int i1,i2,e;
printf("input list:\n");
GreatList_La(NUM);
printf("input other list:\n");
GreatList_Lb(NUM);
MergeList_L();
getch();
}