简单记录,以备后用
public class SelectSort {
public static void main(String[] args) {
int[] arr = { 49, 48, 55, 87, 33, 32, 66, -1, 22 };
selectSort(arr, arr.length);
System.out.println("排序后:");
for (int i : arr) {
System.out.print(i + "-->");
}
}
public static void selectSort(int[] a, int len) {
if(len <= 0) return ;
for(int i=0;i<len;i++) {
int min = i;
for(int j=i;j<len;j++) {
if (a[j] < a[min]) {
min = j;
}
}
if (min != i) {
int temp = a[i];
a[i] = a[min];
a[min] = temp;
}
}
}
}