Skip to content · ⁨ข้ามไปยังเนื้อหา⁩

Tic-tac-toe winner · ⁨ผู้ชนะเกม X O O⁩

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".

ไทย

ผู้ชนะเกม tic-tac-toe

ตัดสินผู้ชนะเกมOXจากกระดานเกม

มีแปดบรรทัดที่ต้องตรวจสอบ: สามแถว สามคอลัมน์ และทแยงมุมสองเส้น board[r][c] คือช่องในแถว r และคอลัมน์ c ดังนั้นคอลัมน์จึงเป็น board[0][c] + board[1][c] + board[2][c] รวบรวมแปดบรรทัดทั้งหมดเป็นสตริงสามตัวอักษร แล้วมองหา "XXX" หรือ "OOO"

Log in or create account · ⁨เข้าสู่ระบบหรือสร้างบัญชี⁩

IGCSE, A-Level & AP