public static void main(String[] args) {
int a[] = { 2, 3, 6, 4, 0, 1, 7, 8, 5, 9 };
bubbleSort(a);
}
private static void bubbleSort(int[] a) {
int temp;
for(int j=0;j<a.length-1;j++){//控制比较轮数
//先写内循环
for(int i=0;i<a.length -1-j;i++){//控制每一轮比较次数
if(a[i] > a[i+1]){
temp = a[i+1];
a[i+1] = a[i];
a[i] = temp;
}
//a[i-1] = a[i];
}
}
for(int i : a){
System.out.print(i+"\t");
}
}