java数组冒泡排序

public class PaiXu1 {
public static void main(String[] args) {
int[] s = {345,879,456,870,221,902,148,234,478};
System.out.println("排序之前:");
System.out.println(Arrays.toString(s));
System.out.println("排序之后:");
int temp = 0;
for (int i = 0;i < s.length-1;i++){
for (int j = 0;j < s.length-1-i;j++){
if (s[j]>s[j+1]){
temp = s[j];
s[j] = s[j+1];
s[j+1] = temp;
}
}
}
System.out.println(Arrays.toString(s));
}
}
上一篇:java打印等腰三角形的两种方法!(根据行数,根据底边长度)


下一篇:Java实现第九届蓝桥杯等腰三角形