题解 | #简单错误记录#
简单错误记录
https://www.nowcoder.com/practice/2baa6aba39214d6ea91a2e03dff3fbeb
import java.util.*; public class Main { public static void main(String[] args) { Scanner fzhinput = new Scanner(System.in); LinkedHashMap <String,Integer> scnr = new LinkedHashMap<>(); while(fzhinput.hasNextLine()){ String falsefiledz = fzhinput.nextLine(); String falsefiledzfg[] = falsefiledz.split("\\\\"); String falsefilename = falsefiledzfg[falsefiledzfg.length-1]; if(falsefilename.length()>20){ falsefilename=falsefilename.substring(falsefilename.length()-20); } scnr.put(falsefilename,scnr.getOrDefault(falsefilename,0)+1); } List<Map.Entry<String,Integer>> input = new ArrayList<>(scnr.entrySet()); int sz = Math.max(0,scnr.size()-8); for(int i =sz;i<scnr.size();i++){ Map.Entry<String,Integer> finput = input.get(i); System.out.println(finput.getKey()+" "+finput.getValue()); } } }