import java.util.Arrays;
//选择排序
public class SelectSort {
public static void main(String[] args) {
int[] a= {11,32,25,65,72,33,89,14,500,1,250};
System.out.println(Arrays.toString(a));
a=selectSort(a);
System.out.println("排序后:"+Arrays.toString(a));
}
//选择排序方法
public static int[] selectSort(int[] a) {
int minThis = 0;
for(int i = 0;i<=a.length-2;i++) {
minThis = a[i];
for(int j=i;j<=a.length-1;j++) {
if(a[j]<minThis) {
minThis = a[j];
a[j] = a[i];
a[i] = minThis;
}
}
}
return a;
}
}
结果: