八大排序算法之 二 选择排序---简单选择排序算法

http://kb.cnblogs.com/page/176818/

package primary;

public class SimplySelectSort {
    public static void main(String[] args){
        int[] array = {2,6,1,9,4,3,23,65,0,7};
        System.out.print("the array before is:");
        for(int i = 0; i <array.length; i++){
            System.out.print(array[i]+"  ");
        }
        System.out.println(" ");
        simplySelectSort(array);
    }
    protected static void simplySelectSort(int[] array){
        int len = array.length;
        for(int i = 0; i < len; i++){
            for(int j = i; j < len; j++){
                if(array[j] < array[i]){
                    int temp = array[j];
                    array[j] = array[i];
                    array[i] = temp;
                }
            }
        }
        for(int z = 0; z < len; z++){
            System.out.print(array[z]+"  ");
        }
    }
}
原文地址:https://www.cnblogs.com/RunForLove/p/4357830.html