package Come.l.A
public class BubbleSortDemo{
public static viod main (String []aegs){
int [] array = {1,4,665,12,47,33,56,12};
for (int i=0,i<array.length-1,i++){
//n个数比较轮数位n-1
for(int j=0;j<array.length-1-i;j++) {
//比较相邻的两个数,小的靠前if(array[j]>array[j+1]) {
//两个数做交换,通过临时变量
int temp=array[j];
array[j]=array[j+1];
array[j+1]=temp;
}
}
}
//把排好序的数组输出
for(int i=0;i<array.length;i++) {
System.out.println(array[i]+" ");
}
}
}