rambless
简单错误记录
https://www.nowcoder.com/practice/2baa6aba39214d6ea91a2e03dff3fbeb
import java.util.*;
import java.io.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
// 注意 hasNext 和 hasNextLine 的区别
Map<String,Integer> map = new LinkedHashMap<>();
List<String> list = new ArrayList<>();
String temp;
while ((temp = in.readLine()) != null && temp.length() > 0) {
//循环记录时
if(!list.contains(temp)) {
String[] array = temp.split(" ");
String num = array[1];
String name = array[0];
name = name.substring(name.lastIndexOf("\\") + 1);
name = name.substring(Math.max(name.length() - 16, 0)) + " " + num;
Integer count = map.get(name);
if(count==null) {
map.put(name, 1);
} else {
map.put(name, ++count);
}
}
}
//记录最多8条错误记录
int count = 0;
for(String s:map.keySet()) {
if(map.size()-count<=8) {
System.out.println(s + " " + map.get(s));
}
count++;
}
}
}