//选择排序
int[] a2 = {4, 2,3,5,1};
for (int i = 0; i < a2.length-1; i++) { // 0,1,2,3
for (int j = i+1; j < a2.length; j++) { //1,2,3,4
int temp = a2[i];
if(a2[i] > a2[j]) {
a2[i] = a2[j];
a2[j] = temp;
}
}
}
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号