import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { Scanner in = new Scanner(System.in); Map<string> strList = new LinkedHashMap<string>(); while (in.hasNextLine()) { String str = in.nextLine(); if (str != null && !str.equals("")) { strList.put(str, null); } } Map<string> resultList = new LinkedHashMap<string>(); strList.forEach((tstr, v) -> { String[] str = tstr.split("\\s+"); String fname = str[0].substring(str[0].lastIndexOf("\\") + 1); fname = fname.substring(Math.max(fname.length() - 16, 0)) + " " + str[1]; resultList.merge(fname, 1, (a, b) -> a + b); }); int count = 0; for (Map.Entry<string> it : resultList.entrySet()) { if (resultList.size() - count <= 8) System.out.println(it.getKey() + " " + it.getValue()); count++; } } } 稍微改一下就行了</string></string></string></string></string>
点赞
牛客网
牛客网在线编程
牛客网题解
牛客企业服务