c++实现算法之选择排序

template<typename T>
void selectionSort(T arr[],int n){
	for(int i = 0; i < n; i++){
		int minIndex = i;
		for(int j = i + 1; j < n; j++){
			if(arr[j] < arr[minIndex]){
				swap(arr[i],arr[minIIndex]);
     		}
		}
	}
}

猜你喜欢

转载自blog.csdn.net/qq_45549336/article/details/107358281