</pre><pre name="code" class="java">public class BubbleSort {
public static void bubbleSort(Integer [] list){
boolean needNextPass = true;
for(int k = 1;k<list.length && needNextPass;k++){
needNextPass = false;
for(int i = 0;i <list.length -k;i++){
if(list[i] > list[i+1]){
int temp = list[i];
list[i] = list[i+1];
list[i+1] = temp;
needNextPass = true;
}
}
}
}
}
冒泡排序
最新推荐文章于 2022-04-29 23:24:15 发布