I would like to improve this code, I am creating a game three in a row and this is an example to determine the winner in the first row.
I would like to reduce it but it works the same.
This is the code:
if (((tablero[0] == tablero[3])&& (tablero[0] == tablero[6])&& (tablero[0] != 0))
|| ((tablero[0] == tablero[6]) && (tablero[0] == tablero[3]) && (tablero[0] != 0))
|| ((tablero[6] == tablero[3])&&(tablero[6]== tablero[0])&&(tablero[6]!=0))
|| ((tablero[6] == tablero[0]) && (tablero[6] == tablero[3]) && (tablero[6] != 0))
|| ((tablero[3] == tablero[0]) && (tablero[3] == tablero[6]) && (tablero[3] != 0))
|| ((tablero[3] == tablero[6]) && (tablero[3] == tablero[0]) && (tablero[3] != 0)))
hay3enRaya = true;
The locations are like this: 0 3 6
- that represents the first row of the 3x3 matrix.