选择排序 Selecttion Sort

来源:互联网 发布:windows驱动开发书籍 编辑:程序博客网 时间:2024/05/14 21:23
template<typename TP>void SelectionSort(TP *_arr, int n){tStart = clock();cout << "SelectionSort";for (int i = 0; i < n-1; i++){int minInx = i;for (int j = i+1; j < n; j++){if (_arr[j] < _arr[minInx]){minInx = j;}}Swap(_arr[i], _arr[minInx]);}tEnd = clock();cout << ""<<(double)(tEnd-tStart)/CLOCKS_PER_SEC << endl;}

0 0
原创粉丝点击