²³æ«¬°}¦C¥æ´«code
public class Object {
static int a[] = { 10, 20, 30, 40 };
public static void main(String[] argv) {
for (int i = 0; i < a.length - 1; i++) {
for (int j = 0; j < a.length - 1 - i; j++) {
ii(j);
}
}
for (int z : a) {
System.out.print(z + " ");
}
System.out.println("");
}
public static void ii(int j) {
int temp;
if (a[j] <= a[j + 1]) {
temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
}
}
} |