原题
http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=1§ionid=3&problemid=11
源码
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while(in.hasNext()) {
String line = in.nextLine();
String[] strs = line.split("[5]");
int length = strs.length;
List<String> list = new ArrayList<>();
//去除字符串数组中 “ "" ” 字符串
for (int i = 0; i < length; i++) {
if(!strs[i].equals(""))
list.add(strs[i]);
}
length = list.size();
int[] nums = new int[length];
for (int i = 0; i < length; i++) {
nums[i] = Integer.parseInt(list.get(i));
}
Arrays.sort(nums);
StringBuilder sb = new StringBuilder();
for (int i = 0;i < length;i++){
sb.append(nums[i]);
if(i + 1 == length) break;
sb.append(" ");
}
System.out.println(sb.toString());
}
}
}