选择排序
时间:2021-07-19 16:29:05
收藏:0
阅读:0
public static void main(String[] args) {
int[] aa = {5, 86, 21, 231, 4, 3, 1, 74};
paixu(aa);
printaaaa(aa);
}
public static void paixu(int[] aa) {
for (int i = 0; i < aa.length - 1; i++) {
for (int o = i + 1; o < aa.length; o++) {
if (aa[i] > aa[o]) {
int p = aa[i];
aa[i] = aa[o];
aa[o] = p;
}
}
}
}
public static void printaaaa(int[] arry) {
for (int i = 0; i < arry.length; i++) {
System.out.println(arry[i]);
}
}
评论(0)