#ifndef SELECTIONSORT
#define SELECTIONSORT
template <typename T>
bool static SelectionSortDefaultCmd(T a,T b){
return (a < b) ;
}
template <typename T>
void Selectionsort(T *array,int low,int high,bool (*cmp)(T,T) = SelectionSortDefaultCmd){
T *best = NULL ;
for(int i = low;i < high;i ++){
best = (array + i) ;
for(int o = (i + 1);o <= high;o ++)
if(cmp(*best,array[o]) == false)
best = (array + o) ;
swap(*best,array[i]) ;
}
return ;
}
#endif
排序算法自实现之选择排序/SelectionSort
于 2024-01-19 17:33:34 首次发布