私は自分の C++ クラス用にこの関数を書き、x <= 4 を試し、x >= 4 も試しましたが、トレースを行ったときに、本来のようにループしていません。5 つの数字の配列を取得して並べ替え、その組み合わせがフルハウスになるかどうかをチェックします。
bool isFullHouse(int)
{
int match = 0;
BubbleSort(DiceHeld, 5);
for ( int x=0; x <= 4; x++ )
{
if (((DiceHeld[1] == x+1) && (DiceHeld[2] == x+1) && (DiceHeld[3] == x+2) && (DiceHeld[4] == x+2) && (DiceHeld[5] == x+2)) ||
((DiceHeld[1] == x+1) && (DiceHeld[2] == x+1) && (DiceHeld[3] == x+1) && (DiceHeld[4] == x+2) && (DiceHeld[5] == x+2)) ||
((DiceHeld[1] == x+1) && (DiceHeld[2] == x+1) && (DiceHeld[3] == x+3) && (DiceHeld[4] == x+3) && (DiceHeld[5] == x+3)) ||
((DiceHeld[1] == x+1) && (DiceHeld[2] == x+1) && (DiceHeld[3] == x+1) && (DiceHeld[4] == x+3) && (DiceHeld[5] == x+3)) ||
((DiceHeld[1] == x+1) && (DiceHeld[2] == x+1) && (DiceHeld[3] == x+4) && (DiceHeld[4] == x+4) && (DiceHeld[5] == x+4)) ||
((DiceHeld[1] == x+1) && (DiceHeld[2] == x+1) && (DiceHeld[3] == x+1) && (DiceHeld[4] == x+4) && (DiceHeld[5] == x+4)) ||
((DiceHeld[1] == x+1) && (DiceHeld[2] == x+1) && (DiceHeld[3] == x+5) && (DiceHeld[4] == x+5) && (DiceHeld[5] == x+5)) ||
((DiceHeld[1] == x+1) && (DiceHeld[2] == x+1) && (DiceHeld[3] == x+6) && (DiceHeld[4] == x+2) && (DiceHeld[5] == x+2)) ||
((DiceHeld[1] == x+1) && (DiceHeld[2] == x+1) && (DiceHeld[3] == x+6) && (DiceHeld[4] == x+6) && (DiceHeld[5] == x+6)) ||
((DiceHeld[1] == x+1) && (DiceHeld[2] == x+1) && (DiceHeld[3] == x+1) && (DiceHeld[4] == x+6) && (DiceHeld[5] == x+6)))
{
match = 1;
}
}
if (match == 1)
{
return true;
}
else
{
return false;
}
}