int[] array = { 2, 4, 6, 1, 9, 13 };
int temp;
for (int i = 0; i < array.length; i++) {
for (int j = i; j < array.length; j++) {
if (array[j] < array[i]) {
temp = array[j];
array[j] = array[i];
array[i] = temp;
}
}
}
for (int i = 0; i < array.length; i++) {
System.out.print(array[i] + " ");
}
冒泡排序
最新推荐文章于 2023-06-06 09:14:05 发布