TreeSet<Integer> liubei = new TreeSet<>();
TreeSet<Integer> sunquan = new TreeSet<>();
TreeSet<Integer> caocao = new TreeSet<>();
TreeSet<Integer> dipai = new TreeSet<>();
for (int i = 0; i < list.size(); i++) {
if (i>=list.size()-3) {
dipai.add(list.get(i));
}else if (i%3==0) {
liubei.add(list.get(i));
}else if (i%3==1) {
sunquan.add(list.get(i));
}else {
caocao.add(list.get(i));
}
}
lookpoker (hm , liubei , "刘备");
lookpoker (hm , sunquan , "孙权");
lookpoker (hm , caocao , "曹操");
lookpoker (hm , dipai , "底牌");
}
public static void lookpoker(HashMap<Integer, String> hm ,TreeSet<Integer> ts ,String name ){
System.out.print(name + "的牌是:");
for (Integer i : ts) {
System.out.print(hm.get(i) + " ");
}
System.out.println();
}
}作者: 丶洛夜 时间: 2015-9-15 21:04
感觉好里还的样子作者: 641113495 时间: 2015-9-15 21:47
没看懂,感觉自己还差好多