源程序如下(帮忙看看有没有错)
#include <iostream>
using namespace std;
const int MaxSize=100;
template <class DataType>
class SeqList
{
public:
SeqList(){length=0;}
SeqList(DataType a[],int n);
~SeqList(){}
int Length(){return length ;}
DataType Get(int i);
int Locate(DataType x);
void PrintList();
DataType Delete(int i);
void printList();
void Insert (int i,DataType x);
void unionList (DataType a[]);
private:
DataType data[MaxSize];
int length;
};
template <class DataType>
SeqList<DataType>::SeqList (DataType a[],int n)
{ int i;
if (n>MaxSize)throw "参数非法";
for (i=0;i<n;i++)
data[i]=a[i];
length=n;
}
template <class DataType>
DataType SeqList <DataType>::Get ( int i)
{ if (i<1&&i>length)throw "查找位置非法";
else return data [i-1];
}
template <class DataType>
int SeqList <DataType>::Locate(DataType x)
{ int i;
for (i=0;i<length ;i++)
if(data[i]==x) return i+1;
return 0;
}
template <class DataType>
void SeqList <DataType>::Insert ( int i,DataType x)
{ int j;
if (length>=MaxSize)throw "上溢";
if (i<1||i>length+1)throw "位置";
for (j=length;j>=i;j--)
data[j]=data[j-1];
data[i-1]=x;
length++;
}
template <class DataType>
DataType SeqList<DataType>::Delete(int i)
{ int j,x;
if(length==0)throw"下溢";
if(i<1||i>length)throw "上溢";
x=data[i-1];
for (j=i;j<length;j++)
data[j-1]=data[j];
length--;
return x;
}
template <class DataType>
void SeqList<DataType>::PrintList()
{ int i;
for(i=0;i<length;i++)
cout <<data[i];
}
template <class DataType>
void SeqList<DataType>::unionList (DataType a[])
{ int lena ,i;
DataType x;
DataType a3[], a1[], a2[];
for (i=1;i<=Length(a1);i++)
{Get(a1,i,x);
Insert(a3,i,x);
}
lena=Length(a1);
for(i=1;i<=Length(a2);i++)
{ Get(a2,i,x) ;
if(!Locate(a1,x))
Locate(a3,++lena,x);
}
}
int main()
{
return 0;
如何main中编写一串程序去检验集合的并对不对?帮忙打出来(本人小白)谢谢