Last active
August 30, 2018 03:15
-
-
Save solome/8781081 to your computer and use it in GitHub Desktop.
SelectionSort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//选择排序 | |
template <typename ElemType> | |
static void SelectionSort(ElemType list[], int start, int end) { | |
for (int i = start; i <= end - 1; ++i) { | |
int max = i; | |
for (int j = i + 1; j <= end; ++j) | |
if (list[j] > list[max]) max = j; | |
if (max != i) | |
Swap<ElemType>(list[i], list[max]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment