Skip to content

Instantly share code, notes, and snippets.

@jeonghwan-kim
Created October 25, 2013 01:21
Show Gist options
  • Select an option

  • Save jeonghwan-kim/7148048 to your computer and use it in GitHub Desktop.

Select an option

Save jeonghwan-kim/7148048 to your computer and use it in GitHub Desktop.
select sort
void select_sort(int a[], int n) {
for (int i = 0; i < n - 1; i++) {
int min = i;
for (int j = i + 1; j < n; j++) {
if (a[j] < a[min]) min = j;
}
// swap
int temp = a[i];
a[i] = a[min];
a[min] = temp;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment