package book; /** * @Auther tangzekai * @Description: * @Date:Created in 11:09 2017/7/3 * @Modified By: */ public class ChooseSort { public static void selectSort(int[] a) { int i,t; for (t = 0; t < a.length-1; t++) { for (i = 0; i < a.length-1; i++) { int temp; if (a[i] >= a[i + 1]) { temp = a[i + 1]; a[i + 1] = a[i]; a[i] = temp; } } } for (int x = 0; x < a.length; x++) { if (x == a.length - 1) { System.out.print(a[x]); } else System.out.print(a[x] + "-"); } } public static void main(String[] args) { int[] b = {77, 22, 3, 55, 47, 96, 12, 12, 15, 11, 19, 33}; selectSort(b); } }