线性表的问题
/* HELLO.C -- Hello, world */#include "stdio.h"
#include "conio.h"
#define MAXSIZE 100
#include "malloc.h"
typedef struct
{
int data[MAXSIZE];
int last;
}SeqList;
SeqList * init_SeqList() /*创建结构体*/
{
SeqList *L;
L=malloc(sizeof(SeqList));
L->last=-1;
return L;
}
void create_SeqList(SeqList *C,int m) /*申请空间*/
{
int i,x;
if(C->last+m==MAXSIZE )
{
printf("out the box");
exit(1);
}
for(i=0;i<5;i++)
{
scanf("%d",&x);
C->last++;
C->data[C->last]=x;
}
}
void print_SeqList(SeqList *C)/*输出表C*/
{
int i;
if(C->last==-1)
{
printf("the table is null");
exit(1);
}
for(i=0;i<=C->last;i++)
{
printf("%d",C->data[i]);
}
printf("\n");
}
void merge(SeqList A,SeqList B,SeqList *C) /*将表A表B的数据放入表C中*/
{
int i,j,k;
i=0,j=0,k=0;
while(i<=A.last&&j<=B.last)
if(A.data[i]<B.data[j])
C->data[k++]=A.data[i++];
else
C->data[k++]=B.data[j++];
while(i<=A.last)
C->data[k++]=A.data[i++];
while(j<=B.last)
C->data[k++]=B.data[j++];
C->last=k-1;
}
main()
{
SeqList *L;
SeqList *C;
SeqList A,B;
int number,a,b;
L=init_SeqList();
b=3;
number=5;
init_SeqList(&A);
init_SeqList(&B);
init_SeqList(&C);
create_SeqList(&A,number);
create_SeqList(&B,number);
merge(A,B,C);
print_SeqList(&C);
getch();
}
怎么不是想要的结果啊