#include<iostream>usingnamespace std;int aList[5];template<classT>classOrderList{private:int maxSize;int curLen;int position;public:OrderList(){
curLen = position =0;}//獲得順序表的長度intgetLength(){return curLen;}//在表尾插入元素boolappend(const T value){if(curLen >= maxSize){
cout <<"The list is overflow!"<< endl;returnfalse;}
aList[curLen]= value;
curLen++;returntrue;}//在指定位置插入元素boolinsert(constint p,const T value){int i;if(curLen >= maxSize){
cout <<"The list is overflow!"<< endl;returnfalse;}elseif(p <=0|| p > maxSize){
cout <<"Insertion point is illegal!"<< endl;returnfalse;}else{for(i = curLen; i > p; i--)
aList[i]= aList[i -1];
aList[p]= value;
curLen++;returntrue;}}//刪除某指定位置的元素booldrop(constint p){int i;if(curLen >= maxSize){
cout <<"The list is overflow!"<< endl;returnfalse;}elseif(p <=0|| p > maxSize){
cout <<"Insertion point is illegal!"<< endl;returnfalse;}else{for(i = p; i < curLen; i++)
aList[i]= aList[i +1];
aList[curLen]='\0';
curLen--;returntrue;}}//設定某指定位置的元素的值boolsetValue(constint p,const T value){int i;if(p <=0|| p > maxSize){
cout <<"Insertion point is illegal!"<< endl;returnfalse;}else{
aList[p]= value;returntrue;}}//獲取某指定位置的元素的值boolgetValue(constint p, T & value){int i;if(p <=0|| p > maxSize){
cout <<"Insertion point is illegal!"<< endl;returnfalse;}else{
value = aList[p];returntrue;}}//查找指定值所對應元素的位置boolgetPos(int& p,const T value){int i;for(i =0; i < curLen; i++){if(value == aList[i]){
p = i;returntrue;}}returnfalse;}};