public class xuanzepaixu {
public static void main(String[] args) {
// 选择排序
int[] x = { 3, 7, 9, 1, 5 };
int temp;
for (int i = 0; i < x.length - 1; i++) {
for (int j = i + 1; j < x.length; j++) {
if (x[i] > x[j]) {
temp = x[i];
x[i] = x[j];
x[j] = temp;
}
}
}
for (int i : x) {
System.out.print(i + " ");
}
}
}
选择排序
最新推荐文章于 2024-10-05 15:09:26 发布