/** * 解题思路:此题其实是冒泡排序的变种 * 比较的不是前后两个元素s1和s2的大小,而是s1+s2和s2+s1的大小,哪个元素放前面的组合更小,就酱这个元素排前面 **/ public String PrintMinNumber(int [] numbers) { if(numbers == null || numbers.length == 0) { return ""; } int temp; for(int i = 0; i < numbers.length; i++) { for(int j = i + 1; j <numbers.length; j ++) { if(Integer.valueOf(numbers[i] + "" + numbers[j]) > Integer.valueOf(numbers[j] + "" + numbers[i])) { temp = numbers[i]; numbers[i] = numbers[j]; numbers[j] = temp; } } } StringBuilder builder = new StringBuilder(); for(int n : numbers) { builder.append(n); } return builder.toString(); }