//是不是有空格,则退出。程序如下
public class Test {
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
char[] c;
String s = null;
while (true) {
try {
s = br.readLine();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (s.contains(" ")) {
System.exit(0);
} else {
c = s.toCharArray();
for (int i = 0; i < c.length - 1; i++) {
for (int j = i; j < c.length - 1; j++) {
if (c[j] > c[j + 1]) {
char temp = c[j];
c[j] = c[j + 1];
c[j + 1] = temp;
}
}
System.out.println("c[" + i + "]=" + c[i]);
}
}
}
}
}
}
java 有封装好的 排序功能 sort();
HashSet