牛客网的在线题。思路,比较简单。就是判断一下是否有连起来的1.
public static boolean checkWon(int[][] board){ boolean res = false; for(int i = 0; i < 3;i++){ if(board[i][0] == 1 && board[i][1] == 1 && board[i][2] == 1){ return true; } if(board[0][i] == 1 && board[1][i] == 1 && board[2][i] == 1 ){ return true; } } if(board[0][0] == 1 && board[1][1] == 1 && board[2][2] == 1){ return true; } if(board[0][2] == 1 && board[1][1] == 1 && board[2][0] == 1){ return true; } return res; }
时间: 2024-10-27 06:25:54