package classes;
import java.util.*;
public class TestSelect{
public static void selectSort(int[] array){
int i,j,minIndex,minValue,temp;
for(i=0;i<array.length-1;i++){
minIndex = i;
minValue = array[i];
for(j=i+1;j<array.length;j++){
if(array[j]<minValue){
minIndex = j;
minValue = array[j];
}//end if
}//end for
if(minIndex!=i){
array[minIndex] = array[i];
array[i] = minValue;
}//end if
}//end for
}//end method selectSort
public static void main(String [] args){
int[] array = new int[12];
for(int i=0; i<array.length; i++){
array[i] = (int)(Math.random()*100);
}//end for
System.out.println(Arrays.toString(array));
selectSort(array);
System.out.println("排序后:");
System.out.println(Arrays.toString(array));
}//end method main
}//end class TestSelect