rows
and cols
of size 3
to zero, representing the sum of values in each row and column.diag
and anti_diag
to zero, representing the sum of values in the diagonal and anti-diagonal.moves
array, alternating between player A and B (starting with A).[row, col]
, add the player's value to rows[row]
and cols[col]
.row == col
), update diag
.row + col == 2
), update anti_diag
.rows[row]
, cols[col]
, diag
, or anti_diag
is 3
. If so, the current player wins.