解题思路:
注意事项:
参考代码:
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 人评分
C语言训练-立方和不等式 (C语言代码)浏览:742 |
数组输出 (C语言代码)--此题的题目描述有问题浏览:1813 |
C语言程序设计教程(第三版)课后习题6.6 (C语言代码)浏览:624 |
C语言程序设计教程(第三版)课后习题8.1 (C语言代码)浏览:1242 |
核桃的数量 (C语言代码)浏览:870 |
程序员的表白 (C语言代码)浏览:587 |
分糖果 (C语言代码)浏览:911 |
整除问题 (C语言代码)浏览:518 |
输入输出格式练习 (C语言代码)浏览:743 |
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:663 |