package com.larry.sorting;
import java.util.Arrays;
public class EasySelectSort {
private void easySelectSort(int s[]){
if(s == null) return;
for(int i = 0; i < s.length; i++){
int index = i;
for(int j = i+1; j < s.length; j++){
if(s[j] < s[index]) index = j;
}
if(index != i){
int temp = s[i];
s[i] = s[index];
s[index] = temp;
}
}
}
public static void main(String[] args) {
int s[] = {23, 13, 49, 6, 31, 19, 28};
new EasySelectSort().easySelectSort(s);
System.out.println(Arrays.toString(s));
}
}
选择排序-简单选择排序
最新推荐文章于 2022-01-07 23:29:38 发布