//冒泡排序
public class ExamTest {
public static void main(String[] args) {
int[] array = { 12, 25, 234, 364, 4, 345, 346, 47 };
for (int a = 0; a < array.length - 1; a++) {
for (int b = 0; b < array.length - 1 - a; b++) {
if (array[b] > array[b + 1]) {
int temp = array[b];
array[b] = array[b + 1];
array[b + 1] = temp;
}
}
}
for (int i : array) {
System.out.println(i);
}
}
} |
|