如果您无法下载资料,请参考说明:
1、部分资料下载需要金币,请确保您的账户上有足够的金币
2、已购买过的文档,再次下载不重复扣费
3、资料包下载后请先用软件解压,在使用对应软件打开
123456template<classT>voidInsertionSort(TA[],intn){inti,j;Ttemp;for(i=1;i<n;i++){j=i;temp=A[i];while(j>0&&temp<A[j-1]){A[j]=A[j-1];j--;}A[j]=temp;}}89template<classT>voidSwap(T&x,T&y){Ttemp;temp=x;x=y;y=temp;}template<classT>voidSelectionSort(TA[],intn){intsmallIndex;inti,j;for(i=0;i<n-1;i++){smallIndex=i;for(j=i+1;j<n;j++)if(A[j]<A[smallIndex])smallIndex=j;Swap(A[i],A[smallIndex]);}}12131415template<classT>voidBubbleSort(TA[],intn){inti,j;intlastExchangeIndex;i=n-1;while(i>0){lastExchangeIndex=0;for(j=0;j<i;j++)if(A[j+1]<A[j]){Swap(A[j],A[j+1]);lastExchangeIndex=j;}i=lastExchangeIndex;}}17template<classT>intSeqSearch(Tlist[],intn,Tkey){for(inti=0;i<n;i++)if(list[i]==key)returni;return-1;}192021while(low<=high){mid=(low+high)/2;midvalue=list[mid];if(key==midvalue)returnmid;elseif(key<midvalue)high=mid-1;elselow=mid+1;}return-1;}23