Skip to content

Instantly share code, notes, and snippets.

@solome
Last active August 30, 2018 03:15
Show Gist options
  • Save solome/8781081 to your computer and use it in GitHub Desktop.
Save solome/8781081 to your computer and use it in GitHub Desktop.
SelectionSort
//选择排序
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