问题描述
解题思路
模拟
代码
class Solution {
public:
bool checkXMatrix(vector<vector<int>> &grid) {
bool res = true;
for (int i = 0; i < grid.size(); i++) {
for (int j = 0; j < grid[0].size(); j++) {
if (i == j || i + j == grid.size() - 1) {
if (grid[i][j] == 0)
return false;
} else {
if (grid[i][j] != 0)
return false;
}
}
}
return true;
}
};
标签:return,2319,矩阵,是否是,grid,size
From: https://www.cnblogs.com/zwyyy456/p/17478039.html