题解 | #简单错误记录#

简单错误记录

http://www.nowcoder.com/practice/2baa6aba39214d6ea91a2e03dff3fbeb

import java.util.*;

public class Main {

public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Map<String,Integer> map = new LinkedHashMap<>();
    while (sc.hasNext()){
        String msg = sc.nextLine();
        String[] s = msg.split(" ");
        String[] split = s[0].split("\\\\");
        String fileName = split[split.length-1];
        String realName;
        if (fileName.length()>=16){
        realName = fileName.substring(fileName.length()-16)+" "+s[1];
        }else{
            realName = fileName+" "+s[1];
        }
        if (map.containsKey(realName)){
            map.put(realName,map.get(realName)+1);
        }else{
            map.put(realName,1);
        }
    }
        Set<String> strings = map.keySet();
    if(map.size()<=8){
        for (String s : strings) {
            System.out.println(s+" "+map.get(s));
        }
    }else{
        List<String> list = new ArrayList<>(strings);
        for (int i = list.size()-8;i < list.size();i++){
            System.out.println(list.get(i) + " " + map.get(list.get(i)));
        }
    }
}

}

全部评论

相关推荐

点赞 评论 收藏
分享
人力小鱼姐:实习经历没有什么含金量,咖啡店员迎宾这种就别写了,其他两段包装一下 想找人力相关的话,总结一下个人优势,结合校园经历里有相关性的部分,加一段自我评价
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务