public static void sort(int []a){ for (int i = 0; i < a.length-1; i++) { int tmp=i; for (int j = i+1; j <a.length ; j++) { if (a[tmp]>a[j]){ tmp=j; } } int t=a[i]; a[i]=a[tmp]; a[tmp]=t; } }
选择排序精简
最新推荐文章于 2024-09-02 22:33:56 发布
public static void sort(int []a){ for (int i = 0; i < a.length-1; i++) { int tmp=i; for (int j = i+1; j <a.length ; j++) { if (a[tmp]>a[j]){ tmp=j; } } int t=a[i]; a[i]=a[tmp]; a[tmp]=t; } }