I'm still stuggling with the game of fifteen, and I could make it works. However, when I run check50 it displays
:( 3x3.txt wins the 3x3 board
\ expected an exit code of 0, not a prompt for input
:( 4x4.txt wins the 4x4 board
\ expected an exit code of 0, not a prompt for input
Every change I made, I get the same error...
I know that it's an error in my WON function, that keeps prompting for input instead of exit with code 0. But I couldn´t solve it so far...
My code initially was
bool won(void)
{
// TODO
int n = 0;
for (int i = 0; i < d; i++)
{
for (int j = 0; j < d; j++)
{
n ++;
if (board[i][j] != n)
{
return false;
}
}
}
return true;
}
Now, it's
bool won(void)
{
// TODO
int n = 1;
for (int i = 0; i < d; i++)
{
for (int j = 0; j < d; j++)
{
if (board[i][j] < board[d-1][d-1])
{
if (board[d-1][d-1] == 0 && board[i][j] == n)
{
return true;
}
}
n++;
}
}
return false;
}
I'd be very grateful if you could hint me what I'm doing wrong.