一个双层for循环

import java.util.*;

public class Board {
    public boolean checkWon(int[][] board) {
        int len = board.length;//棋盘的横向或纵向长度
        int sum1 = 0;//用于判断横向
        int sum2 = 0;//用于判断纵向
        int sum3 = 0;//用于判断主对角线
        int sum4 = 0;//用于判断副对角线
        for(int i = 0; i < len; ++i){
            //每次需要清空
            sum1 = 0;
            sum2 = 0;
            //主对角线
            sum3 += board[i][i];
            //副对角线
            sum4 += board[i][len - 1 - i];
            for(int j = 0; j < len; ++j){
                sum1 += board[i][j];
                sum2 += board[j][i];
            }
            if(sum1 == len || sum2 == len || sum3 ==len || sum4 == len){
                return true;
            }
        }
        return false;
    }
}