Im having trouble with getting this function to work. It is supposed to return true if 3 elements in row in the matrix are the same(vertical or horizontal). Can somebody tell me what im doing wrong.
bool compare(int matrix[][SIZE], int SIZE)
{
for(int y = 0; y < SIZE; y++)
{
for(int x = 0; x < SIZE; x++)
{
if(x ==y) //at diagonal element
{
//check for any element accors the diagonal row and diagonal column that repeats itself 3 times.
for(int i = 0; i < SIZE; i++) //this can be a row or column, depends on the if statments below
{
int rowCount = 0, colCount = 0;
for(j = 0; j < SIZE; j++) //search the line row or column for that matrix[i] and count its occurance
{
if(matrix[i][y] == matrix[j][y]) //search row, NOTE that y is constant to mean the same row
++rowCount;
if(matrix[x][i] == matrix[x][j]) //search col
++colCount;
}
if(rowCount == 3 || colCount == 3) //no need to explain
returntrue;
}
}
}
}
returnfalse;
}