每种语言都有冒泡JAVA实现如下:
public static void main(String args[]){ System.out.println("Start"); int[] sort ={5,2,6,8,3,1,9,0,4}; Sort(sort); System.out.println("End"); } public static int[] Sort(int[] sort){ for (int i=0;i<sort.length-1;i++){ for (int j=0;j<sort.length-1;j++){ if(sort[j]>sort[j+1]){ int temp = sort[j]; sort[j] = sort[j+1]; sort[j+1] = temp; } } } return sort; }