package com.hb.selectSort;
public class SelectSort {
public static void main(String[] args){
int[] a = new int[] {6,1,54,2,7,8};
System.out.println("排序前:");
for (int n = 0; n < a.length; n++) {
System.out.print(a[n] + " ,");
}
for(int i=0; i int min = i;
for(int j=i+1; j if(a[j] < a[min]){
min = j;
}
}
int temp = a[i];
a[i] = a[min];
a[min] = temp;
}
System.out.println("\n排序后:");
for (int n = 0; n < a.length; n++) {
System.out.print(a[n] + " ,");
}
}
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9474419/viewspace-478432/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9474419/viewspace-478432/