//SeqList.h #includeusing namespace std;const int DefaultSize=100;template class SeqList{public: SeqList(int sz=DefaultSize):m_nmaxsize(sz),m_ncurrentsize(-1) { if(sz>0){ m_elements=new Type[m_nmaxsize]; } } ~SeqList(){ delete [] m_elements; } int Length() const{ //get the length return m_ncurrentsize+1;}int Find(Type x) const; //findthe position of xint IsElement(Type x) const; //isit in the listint Insert(Type x,int i); //insertdataint Remove(Type x); //deletedataint IsEmpty(){ return m_ncurrentsize==-1;}int IsFull(){ return m_ncurrentsize==m_nmaxsize-1;}Type Get(int i){ //getthe ith data return i<0||i>m_ncurrentsize?(cout<<"can'tfind the element"< int SeqList ::Find(Type x) const{for(int i=0;i int SeqList ::IsElement(Type x) const{if(Find(x)==-1) return 0;else return 1;}template< typename Type > int SeqList ::Insert(Type x, int i){if(i<0||i>m_ncurrentsize+1||m_ncurrentsize==m_nmaxsize-1){cout<<"theoperate is illegal"< i;j--){m_elements[j]=m_elements[j-1];}m_elements[i]=x;return 1;}template int SeqList ::Remove(Type x){int size=m_ncurrentsize;for(int i=0;i void SeqList ::Print(){for(int i=0;i<=m_ncurrentsize;i++)cout< <<":\t"< < < <
// Test.cpp#include#include "SeqList.h"using namespace std;int main(){SeqList test(15);int array[15]={2,5,8,1,9,9,7,6,4,3,2,9,7,7,9};for(int i=0;i<15;i++){test.Insert(array[i],0);}test.Insert(1,0);cout<<(test.Find(0)?"can'tbe found ":"Befound ")<<0 << endl<
$ ./Ex_Seqlist
theoperate is illegalcan'tfind the element you want to findcan'tbe found 01: 92: 93: 24: 35: 46: 67: 98: 99: 110: 811: 512: 21: 22: 33: 44: 65: 16: 87: 58: 2can'tfind the element you want to remove1: 22: 33: 44: 65: 16: 87: 58: 2