int [] arr={20,35,18,3,47,8};
for (int i = 0; i < arr.length; i++) {
int m=i;
for (int j = i+1; j < arr.length; j++) {
if(arr[m]>arr[j]){
m=j;
}
}
if(i!=m){
int temp=arr[i];
arr[i]=arr[m];
arr[m]=temp;
}
}
System.out.println(Arrays.toString(arr)); //转换成字符串输出
|