题解 | #HJ019 简单错误记录#
简单错误记录
http://www.nowcoder.com/practice/2baa6aba39214d6ea91a2e03dff3fbeb
import java.util.*;
/**
* HJ19 简单错误记录
*/
public class HJ019 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Map<String, Integer> map = new LinkedHashMap();
while (sc.hasNext()) {
String tstr = sc.nextLine();
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];
Integer tmp = map.get(fname);
if (tmp == null) {
map.put(fname, 1);
} else {
map.put(fname, tmp + 1);
}
}
int count = 0;
for (Map.Entry<String, Integer> it : map.entrySet()) {
if (map.size() - count <= 8) {
System.out.println(it.getKey() + " " + it.getValue());
}
count++;
}
sc.close();
}
}
深信服公司福利 729人发布
