解题思路:
注意事项:
参考代码:
import java.io.*; import java.util.LinkedHashMap; import java.util.Map; import java.util.Scanner; public class Main { static Scanner cin; static PrintWriter out; static Map<String, Integer> dic = new LinkedHashMap<>(); public static void main(String[] args) throws IOException{ cin = new Scanner(System.in); out = new PrintWriter(new OutputStreamWriter(System.out)); int max = -1; while(cin.hasNext()){ String value = cin.next().toUpperCase(); if(value.charAt(value.length()-1) == '.' || value.charAt(value.length()-1) == ',') value = value.substring(0, value.length()-1); max = Math.max(max, value.length()); dic.put(value, dic.getOrDefault(value, 0)+1); } for(Map.Entry<String, Integer> ele : dic.entrySet()){ out.printf("%"+max+"s", ele.getKey()); out.print(":"); for(int i = 0; i < ele.getValue(); i++){ out.print('*'); } out.println(ele.getValue()); } out.flush(); } }
0.0分
0 人评分
多输入输出练习1 (C语言代码)浏览:1187 |
最小公倍数 (C语言代码)浏览:863 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:449 |
C二级辅导-同因查找 (C语言代码)浏览:568 |
一元一次方程 (C语言代码)浏览:4069 |
陶陶摘苹果2 (C语言代码)浏览:601 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:595 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:554 |
【计算直线的交点数】 (C语言代码)浏览:922 |
C语言程序设计教程(第三版)课后习题6.5 (C语言代码)浏览:496 |