public class Untitled3 {
public Untitled3() {
} public static void main(String[] args) {
int[] array = {13, 4, 56, 18, 300, 48, 4};
int length = array.length; for (int i = 0; i < length; i++) {
for (int j = 0; j < length - i - 1; j++) {
int tem; if (array[j] > array[j + 1]) {
tem = array[j];
array[j] = array[j + 1];
array[j + 1] = tem;
}
}
}
for (int i = 0; i < length; i++) {
System.out.print(array[i] + ", ");
}
}
}
public Untitled3() {
} public static void main(String[] args) {
int[] array = {13, 4, 56, 18, 300, 48, 4};
int length = array.length; for (int i = 0; i < length; i++) {
for (int j = 0; j < length - i - 1; j++) {
int tem; if (array[j] > array[j + 1]) {
tem = array[j];
array[j] = array[j + 1];
array[j + 1] = tem;
}
}
}
for (int i = 0; i < length; i++) {
System.out.print(array[i] + ", ");
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货