题目1001:A+B for Matrices
2017-04-12 08:41
459 查看
#include <iostream>
#include <stdio.h>
int main()
{
int M ,N ;
while(scanf("%d %d",&M,&N) && M != 0){
int a[M]
, b[M]
,cnt=0;
for(int i=0;i<M;i++)
for(int j=0;j<N;j++)
scanf("%d",&a[i][j]);
for(int i=0;i<M;i++)
for(int j=0;j<N;j++)
scanf("%d",&b[i][j]);
for(int i=0;i<M;i++)
for(int j=0;j<N;j++)
a[i][j]=a[i][j] + b[i][j];
for(int i=0;i<M;i++){
for(int j=0;j<N;j++){
if(a[i][j] != 0)
break;
if(j == N-1 && a[i][j]==0)
cnt++;
}
}
for(int i=0;i<N;i++){
for(int j=0;j<M;j++){
if(a[j][i] != 0)
break;
if(j == M-1 && a[j][i]==0)
cnt++;
}
}
printf("%d\n",cnt);
}
return 0;
}
/**************************************************************
Problem: 1001
User: cust123
Language: C++
Result: Accepted
Time:0 ms
Memory:1520 kb
****************************************************************/
相关文章推荐
- 9度oj 题目1001:A+B for Matrices【水题】
- 九度OJ—题目1001:A+B for Matrices
- 九度 题目1001:A+B for Matrices
- 题目1001: A+B for Matrices
- 题目1001:A+B for Matrices
- 题目1001:A+B for Matrices
- 题目1001:A+B for Matrices
- 九度OJ 题目1001:A+B for Matrices
- 九度 题目1001:A+B for Matrices
- 题目1001:A+B for Matrices
- 题目1001:A+B for Matrices
- 【九度OJ】题目1001:A+B for Matrices
- 题目1001:A+B for Matrices
- 题目1001:A+B for Matrices
- 题目1001:A+B for Matrices
- 题目1001:A+B for Matrices
- 题目1001:A+B for Matrices
- 题目1001:A+B for Matrices
- 九度oj 题目1001:A+B for Matrices 【ZJU2011考研机试题1】
- 【C语言】题目1001:A+B for Matrices【学好英语很重要】