package sort;
public class BubbleSort {
public static void main(String[] args) {
int[] array = { 72, 6, 57, 88, 60, 42, 83, 73, 48, 85 };
BubbleSort(array);
for (int i : array) {
System.out.println(i);
}
}
private static void BubbleSort(int[] array) {
int len = array.length;
for (int i = 0; i < len - 1; i++) {
for (int j = len - 1; j > i; j--) {
if (array[j] < array[j - 1]) {
int temp = array[j];
array[j] = array[j - 1];
array[j - 1] = temp;
}
}
}
}
}
网友评论