import java.util.*; public class Main{ public static void main(String[] args) { HashMap<Character,Integer> map = new HashMap<Character, Integer>(); Scanner sc = new Scanner(System.in); String str = sc.nextLine(); int value; for (int i = 0; i < str.length(); i++) { //判断是否存在"键"不存在则创建 if(!map.containsKey(str.charAt(i))){ map.put(str.charAt(i),1); }else { value = map.get(str.charAt(i)); map.put(str.charAt(i),value += 1); } } Collection<Integer> cl = map.values(); Object num[] = cl.toArray(); Arrays.sort(num); // 先把object对象转换成String,在用Inetger里的parseInt转成int int max=Integer.parseInt(num[num.length-1].toString()); int min=Integer.parseInt(num[0].toString()); System.out.println(max-min); } }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:692 |
【回文数(二)】 (C语言代码)浏览:855 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:683 |
成绩转换 (C语言代码)浏览:1008 |
1642题解浏览:715 |
愚蠢的摄影师 (C++代码)浏览:938 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:470 |
C语言程序设计教程(第三版)课后习题9.10 (C语言代码)浏览:622 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:523 |
10月月赛题解浏览:536 |