I have an 5x10 array that is populated with random values 1-5. I want to be able to check when 3 numbers, either horizontally, or vertically, match. I can\'t figure out a wa
for the record:
I think you mean
for(i = 0; i < 5; i++)
{
board[row][i] = rand()%5 + 1;
cout << board[row][i] << " ";
}
And since others posted Code, here is how I would do it :
for(int i = 0 ; i < 8 ; i++)
{
for(int j = 0 ; j < 3 ; j++)
{
if( ((board[i][j] == board[i][j+1]) && (board[i][j+1] == board[i][j+2])))
std::cout << "Found a horizontal match on " << i << " " << j << std::endl;
if((board[i][j] == board[i+1][j]) && (board[i+1][j] == board[i+2][j]))
std::cout << "Found a vertical match on " << i << " " << j << std::endl;
}
}