正在加载图片...
直接插入排序的算法 template <class Type> void datalist <Type>: InsertSort(i ∥按排序码Key非递减顺序对表选行排序 Element<Type>temp; int 1,]; for(i=l; i< currentSize; 1++)t if( Vector[i]< Vectori-11 temp=Ⅴ ector for(j=i;j>0;j-)∥从后向前顺序比较 if temp Vectorlj-I) Vector [il= vector[i-1 else break直接插入排序的算法 template <class Type> void dataList <Type> :: InsertSort ( ) { //按排序码 Key 非递减顺序对表进行排序 Element<Type> temp; int i, j; for ( i = 1; i < CurrentSize; i++ ) { if ( Vector[i] < Vector[i-1] ) { temp = Vector[i]; for ( j = i; j > 0; j-- ) //从后向前顺序比较 if ( temp < Vector[j-1] ) Vector[j] = Vector[j-1]; else break;
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有