选择排序

public class SelectionSort{
	public static void main(String[] args){
		int arr1[] = new int[args.length];
		for(int i=0;i<args.length;i++){
			arr1[i] = Integer.decode(args[i]);
		}
		for(int i=0;i<args.length;i++){
			int k=i;
			for(int j =k+1;j<args.length;j++){
				if(arr1[j]<arr1[k]){
					k = j;
				}
				if(i != k){
					int temp = arr1[i];
					arr1[i] = arr1[k];
					arr1[k] = temp;
				}
			}
		}
		for(int i=0;i<args.length;i++){
			System.out.println(arr1[i]);
		}
	}
}

你可能感兴趣的:(java)