用ASCII码来解决
字符串归一化
http://www.nowcoder.com/questionTerminal/6d5e036defdf408681376a4a9d4930ff
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.nextLine(); int[] arr = new int [26]; char c; for(int i = 0; i < s.length(); i ++) { c = s.charAt(i); arr[(int)c - 97]++; } for (int i = 0; i < arr.length; i++) { if (arr[i] > 0) { System.out.print((char)(i+97)); System.out.print(arr[i]); } } } }