[AppleScript] 纯文本查看 复制代码 public class test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.println("请输入");
TreeMap<Character, Integer> tm = new TreeMap<>();
String s = sc.nextLine();
char[] arr = s.toCharArray();
for (char c : arr) {
if (!tm.containsKey(c)) {
tm.put(c, 1);
} else {
tm.put(c, tm.get(c) + 1);
}
}
for (char c : tm.keySet()) {
System.out.println(c+" "+tm.get(c));
}
}
} |