//土尔逊Torson 编写于2023/05/20 #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cstdio> using namespace std; struct Matrix079 { //定义矩阵 int matrix079[10][10]; int row, col; Matrix079(int r,int c) : row(r), col(c) {} }; Matrix079 GetMatrix(Matrix079 x) { //获得矩阵 for (int i = 0; i < x.row; ++i) { for (int j = 0; j < x.col; ++j) { scanf("%d", &x.matrix079[i][j]); } } return x; } Matrix079 AddMatrix(Matrix079 a, Matrix079 b) { //矩阵相加 Matrix079 answer(a.row, a.col); for (int i = 0; i < a.row; ++i) { for (int j = 0; j < a.col; ++j) { answer.matrix079[i][j] = a.matrix079[i][j] + b.matrix079[i][j]; } } return answer; } int FindZero(Matrix079 x) { //统计矩阵中全为零的行和列的数目的函数 int horizontal = 0, vertical = 0; int count = 0; for (int i = 0; i < x.row; ++i) { for (int j = 0; j < x.col; ++j) { if (0 == x.matrix079[i][j]) { ++horizontal; if (x.col == horizontal) { ++count; } } } horizontal = 0; } for (int j = 0; j < x.col; ++j) { for (int i = 0; i < x.row; ++i) { if (0 == x.matrix079[i][j]) { ++vertical; if (x.row == vertical) { ++count; } } } vertical = 0; } return count; } void MyPrint(int x) { //输出 printf("%d\n", x); } int main() { int M, N; while (scanf("%d%d", &M, &N) != EOF) { if (M == 0) { break; } Matrix079 A(M, N); //定义 A B Matrix079 B(M, N); A = GetMatrix(A); //获得 A B B = GetMatrix(B); Matrix079 answer = AddMatrix(A, B); //A B 相加 A+B int zero = FindZero(answer); //统计全为零的行和列的数量 MyPrint(zero); //输出结果 } system("pause"); return EXIT_SUCCESS; } // 64 位输出请用 printf("%lld")