import java.util.*;
class Example {
public static void bubbleSort(int[] a) {
for (int k=a.length-1; k>0; k--) {
for (int i=0; ia[i+1]) {
int temp=a[i];
a[i]=a[i+1];
a[i+1]=temp;
}
System.out.println(Arrays.toString(a));
try {
Thread.sleep(500);
} catch(Exception e){}
}
}
}
public static void main(String args[]) {
int[] ar={98,78,56,34,23,58,21,67,37,8};
System.out.println(Arrays.toString(ar));
bubbleSort(ar);
System.out.println(Arrays.toString(ar));
}
}
答案 0 :(得分:0)
转到Google,输入" Java选择排序"并单击任何搜索结果。 例如:http://www.java2novice.com/java-sorting-algorithms/selection-sort/