Java选择排序
public class Test{
public static void main(String args[]){
int[] a = {34, 53, 13, 90, 78,99};
print(a);
selectSort(a);
print(a);
}
public static void print(int[] a){
for(int i = 0; i < a.length; i++){
System.out.print(a[i] + " ");
}
System.out.println();
}
public static void selectSort(int[] a){
int k, temp;
for(int i = 0; i < a.length; i++){
k = i;
for(int j = i + 1; j < a.length; j++){
if(a[j] < a[i]){
k = j;
}
}
if(k != i){
temp = a[k];
a[k] = a[i];
a[i] = temp;
}
}
}
}
追求永不止步