Skip to content

Tic-tac-toe winner · ⁨井字棋赢家⁩

English

Tic-tac-toe winner

Decide a game of noughts and crosses from the board.

There are eight lines to check: three rows, three columns and two diagonals. board[r][c] is the square in row r and column c, so a column is board[0][c] + board[1][c] + board[2][c]. Collect all eight lines as three-letter strings, then look for "XXX" or "OOO".

中文

井字棋赢家

根据棋盘判断井字棋的胜负。

一共要检查八条线:三行、三列和两条对角线。board[r][c] 是第 r 行、第 c 列的格子,所以一列是 board[0][c] + board[1][c] + board[2][c]。把八条线都收集成三个字母的字符串,再查找 "XXX" 或 "OOO"。

Log in or create account · ⁨登录或创建账户⁩

IGCSE, A-Level · ⁨IGCSE、A-Level⁩ & AP · ⁨与 AP⁩