Mr.Clutch


私信TA

用户名:uq_63396757599

访问量:5226

签 名:

等  级
排  名 2462
经  验 2199
参赛次数 0
文章发表 20
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

解题思路:

注意事项:

参考代码:

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 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区