Skip to content

Instantly share code, notes, and snippets.

@onlylemi
Created May 27, 2016 04:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onlylemi/abf17d91eed0f9cce84e9a998c536c4b to your computer and use it in GitHub Desktop.
Save onlylemi/abf17d91eed0f9cce84e9a998c536c4b to your computer and use it in GitHub Desktop.
【算法】选择排序
public void sort(int[] arr) {
int min, k;
for (int i = 0; i < arr.length - 1; i++) {
min = arr[i];
k = i;
for (int j = i + 1; j < arr.length; j++) {
if (arr[j] < min) {
k = j;
min = arr[j];
}
}
int temp = arr[i];
arr[i] = arr[k];
arr[k] = temp;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment