package com.hp.Demo;
//选择排序
public class Demo3 {
public static void main(String[] args) {
int []arr={6,4,2,5,3,1};
for (int i = 0; i <arr.length-1 ; i++) {
for (int j = i+1; j <arr.length; j++) {
if (arr[i]>arr[j]) {
int temp = arr[i];
arr[i]=arr[j];
arr[j]= temp;
}
}
}
for (int i = 0; i <arr.length ; i++) {
System.out.println(arr[i]+"\t");
}
}
}
09-28
169
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交