The examples I've been able to find on this board seem to use numerous if statements.. I was wondering if there was another way? I've tried the following for statements, but they cause the program to crash when the function is called.
Yep.. this is a school assignment, but I'm not expecting it to be written for me, I just need a little nudge in the right direction. Any help would be appreciated, thanks.Code:for(Row = 0; Row < Board.numrows(); Row++)
{
if((Board[Row][0] == Board[Row][1]) && (Board[Row][2] == ' ') && (Board[Row][0] != ' ') && (Board[Row][1] != ' '))
{
//Row = Row;
Col = 2;
}
if((Board[Row][0] == Board[Row][2]) && (Board[Row][1] == ' ') && (Board[Row][0] != ' ') && (Board[Row][2] != ' '))
{
// Row = Row;
Col = 1;
}
if((Board[Row][1] == Board[Row][2]) && (Board[Row][0] == ' ') && (Board[Row][1] != ' ') && (Board[Row][2] != ' '))
{
// Row = Row;
Col = 0;
}
}
for(Col = 0; Col < Board.numcols(); Col++)
{
if((Board[0][Col] == Board[1][Col]) && (Board[2][Col] == ' ') && (Board[0][Col] != ' ') && (Board[1][Col] != ' '))
{
Row = 2;
// Col = Col;
}
if((Board[0][Col] == Board[2][Col]) && (Board[1][Col] == ' ') && (Board[0][Col] != ' ') && (Board[2][Col] != ' '))
{
Row = 1;
// Col = Col;
}
if((Board[1][Col] == Board[2][Col]) && (Board[0][Col] == ' ') && (Board[1][Col] != ' ') && (Board[2][Col] != ' '))
{
Row = 0;
// Col = Col;
}
}