public void arrayClooseSort() {
int[] num = {10,14,3,8,11,9,2,4};
//选择排序,升序排序
for(int i = 0;i < num.length-1;i++) {
for(int j = i + 1;j < num.length;j++) {
if(num[i] > num[j]) {
int temp = num[i];
num[i] = num[j];
num[j] = temp;
}
}
}
System.out.println();
//遍历数组
System.out.println("选择排序数组:");
for(int i : num) {
System.out.print(i+",");
}
}
原文地址:https://www.cnblogs.com/private-mingmie/p/11826642.html
时间: 2024-10-04 06:52:51