#include
using namespace std;
const int MaxSize=200;
class SeqList
{ public:
SeqList(int a[],int n);
int Length();
void Insert(int b[],int length2);
void PrintList();
private:
int data[MaxSize];
int length;
};
SeqList::SeqList(int a[],int n)
{int i;
if(n>MaxSize)throw"
参数非法
";
for(i=0;idata[i]=a[i];
length=n;
}
int SeqList::Length()
{
return length;
}
void SeqList::Insert(int b[],int length2)
{ int j,h,i=0;
for( j=0;j{if(b[i]{ for(h=length;h!=j;--h)
data[h]=data[h-1];
data[j]=b[i];
++length;
++i;
}
else if(j==length-1&&b[i]>data[length-1])
{
data[length]=b[i];
length++;
++i;
}
}
}
void SeqList::PrintList()
{for(int i=0;icout<cout< }
void main()
{
int a[6]={1,5,8,10,15,21};
int b[3]={6,13,18};
SeqList s(a,6);
SeqList c(b,3);
cout<<"
合并前的顺序表
A"<
s.PrintList();
cout<<"
合并前的顺序表
B"<
c.PrintList();
cout<<"
合并后的顺序表
C"<
int x=c.Length();
s.Insert(b,x);
s.PrintList();
}
这个我会,可以帮你写!