#include <iostream.h>
#include<string.h>
#include<iomanip.h>
#include<stdio.h>
#define MAXLEN 100
struct SeqList{
int data[MAXLEN];
int last;
struct SeqList *next;
};
/*初始化*/
void InitSeqList(SeqList *A,SeqList *B,SeqList *C)
{
A->last=-1;
B->last=-1;
C->last=-1;
}
int InsertSeqList(SeqList *A,SeqList *B,SeqList *C)
{
int j=A->last;int n,t;
for(int i=0;i<=j;i++){
C->data[i]= A->data[i];
C->last++;
}
for(int k=1;k<=B->last+1;k++){
C->data[j+k]=B->data[k-1];
C->last=A->last +B->last +1;
n=C->last;
}
for(i=0;i<n;i++){
for(j=0;j<n-i;j++){
if(C->data [j]>C->data [j+1]){
t=C->data [j];
C->data [j]=C->data [j+1];
C->data [j+1]=t;
}
}
}
return 1;
}
/*顺序输出表*/
void Display(SeqList *list)
{
for(int i=0;i<=list->last;i++)
cout<<list->data[i]<<" ";
cout<<endl;
}
void main()
{
SeqList A;
SeqList B;SeqList C;
InitSeqList(&A,&B,&C);//空表
A.data[0]=1;
A.data[1]=7;
A.data[2]=8;
A.last=2;
B.data[0]=2;
B.data[1]=4;
B.data[2]=6;
B.data[3]=8;
B.data[4]=10;
B.data[5]=11;
B.last=5;
Display(&A);
Display(&B);
InsertSeqList(&A,&B,&C);
Display(&C);
}
结果