package com.hb.bubbleSort;
public class BubbleSort {
public static void main(String[] args){
int a[] = new int[]{1,9,3,52,5,6};
System.out.println("排序前:");
for(int n=0; n System.out.print(a[n]+" ,");
}
boolean change = true;
for(int i=a.length; i>0 && change; i-- ){
for(int j=0; j change = false;
if(a[j]>a[j+1]){
int temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
change = true;
}
}
}
System.out.println("\n排序后:");
for(int n=0; n System.out.print(a[n]+" ,");
}
}
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9474419/viewspace-478434/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9474419/viewspace-478434/