Tic-tac-toe winner · ผู้ชนะเกม X O O
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"
Write winner(board). board is a list of three strings, one per row, using X, O, and . for an empty square. Return "X" or "O" if that player has three in a row, column or diagonal, otherwise "". · เขียน winner(board). board เป็นรายการของสามสตริง สตรี้งต่อแถว ใช้ X, O, และ . дляช่องว่าง. คืน "X" หรือ "O" หากผู้เล่นนั้นมี 3 ตัวเรียงกันแนวนอน คอลัมน์ หรือทแยงมุม มิฉะนั้นคืน ""
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่