运行此方法需要为main方法传递参数
package com.zuidaima.sort;
/**
[email protected] www.zuidaima.com
**/
public class TestSort {
public static void main(String args[]){
int l = args.length;
int[] a = new int[l];
for(int i = 0;i < l;i++){
a[i] = Integer.parseInt(args[i]);
}
for(int i = 0;i < l;i++){
int k = i;
int j;
for(j = k + 1;j < l;j++){
if(a[j] < a[k]){
k = j;
}
}
System.out.print("j = " + j);
if(k != i){
int temp = a[i];
a[i] = a[k];
a[k] = temp;
}
}
System.out.println();
for(int i = 0;i < l;i++){
System.out.print(" a[" + i +"]:" + a[i]);
}
}
}