package com.imooc.algorithm.selectsort;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class SelectionSort {
//排序方法1
public static int[] selectSort(int[] array,int length){
for(int i=0;i
//找比第一个数小的数,与第一个数互换
for(int j=i+1;j
int MIN_NUM = array[i];
if(array[j]
array[i] = array[j];
array[j] = MIN_NUM;
MIN_NUM = array[j];
}
}
}
return array;
}
//排序方法2
public static int[] insertSort(int[] array,int length){
for(int i=0;i
int MIN_index = i;
//找最小的数,记录索引
for(int j=i+1;j
if(array[j]
MIN_index = j;
}
}
//二数互换
int temp = array[MIN_index];
array[MIN_index] =