import java.util.Scanner; import java.util.Set; import java.util.TreeMap; public class CalcGeWei { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); // String s= new String(); String line = sc.nextLine(); TreeMap<Character,Integer> tm = new TreeMap<Character,Integer>(); char[] ch = line.toCharArray(); for(char c:ch) { Integer i = tm.get(c); if(i==null) { tm.put(c, 1); } else { i++; tm.put(c, i); } } StringBuffer sb = new StringBuffer(); Set<Character> s1 = tm.keySet(); for(Character c2:s1) { sb.append(c2).append(":").append(tm.get(c2)).append("\n3"); } //System.out.println(tm); String result = sb.toString(); System.out.println(result); } }
点赞 评论

相关推荐

11-08 13:58
门头沟学院 Java
程序员小白条:竟然是蓝桥杯人才doge,还要花钱申领的offer,这么好的公司哪里去找
点赞 评论 收藏
分享
牛客网
牛客企业服务