import java.util.Arrays;
import java.util.Scanner;
public class GetSort {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.next();
boolean flag = Reverse.isNum(str);
if (flag) {
Reverse.sort(str.toCharArray());
} else {
Reverse.sort(str);
}
}
}
class Reverse {
private Reverse() {
}
// 判断键盘录入的内容是否为整数
public static boolean isNum(String str) {
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) < '0' || str.charAt(i) > '9')
return false;
}
return true;
}
// 整数从小到大顺序输出
public static void sort(char[] c) {
Arrays.sort(c);
System.out.println(c);
}
// 字符串反序输出
public static void sort(String str) {
System.out.println(new StringBuffer(str).reverse().toString());
}
} |
|