class SelectSort{ public void sort(int[] a){ for (int i = 0; i < a.length - 1; i++) {//一共进行n-1趟 int min = i;//记录最小元素位置 for (int j = i+1; j < a.length; j++) { if (a[j] < a[min]) min = j; } if (min != i){ int temp = a[min]; a[min] = a[i]; a[i] = temp; } } } }
标签:temp,min,int,选择,++,length,简单,排序 From: https://www.cnblogs.com/jixian/p/17155070.html