import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class LaiZiTingPai {
public static void main(String[] args) {
}
/**
* @param mah 整副牌
* @param laiZi 癞子的那张牌
* @return
*/
public boolean myLaiZiTingPai(List<Integer> mah,Integer laiZi) {
return laiZiCanHu(mah,laiZi);
}
// 癞子是否可以胡
public static boolean laiZiCanHu(List<Integer> mah, Integer laiZi) {
List<Integer> pais = new ArrayList<Integer>(mah);
// 先排序
Collections.sort(pais);
if (pais.size() == 2) {
if (pais.get(0) == pais.get(1)) {
return true;
}
if (pais.contains(laiZi)) {
return true;
}
return false;
}
int laiZiNum = 0;
for (Integer integer : pais) {
if (integer == laiZi) {
laiZiNum++;
}
}
for (int i = 0; i < laiZiNum; i++) {
pais.remove(laiZi);
}
// 依据牌的顺序从左到右依次分出将牌
for (int i = 0; i &
癞子胡牌(听牌)算法
最新推荐文章于 2021-03-20 10:18:07 发布