_jobdu_1001
/************************************************************************/
/* 题目描述:
This time, you are supposed to find A+B where A and B are two matrices, and then count the number of zero rows and columns.
输入:
The input consists of several test cases, each starts with a pair of positive integers M and N (≤10) which are the number of rows and columns of the matrices, respectively. Then 2*M lines follow, each contains N integers in [-100, 100], separated by a space. The first M lines correspond to the elements of A and the second M lines to that of B.
The input is terminated by a zero M and that case must NOT be processed.
输出:
For each test case you should output in one line the total number of zero rows and columns of A+B.
样例输入:
2 2
1 1
1 1
-1 -1
10 9
2 3
1 2 3
4 5 6
-1 -2 -3
-4 -5 -6
0
样例输出:
1
5 */
/************************************************************************/
#include <iostream>
using namespace std;
//#define MAXCOL 10
//#define MAXINT 100
//#define MININT -100 int main()
{
short arr[][];
short m, n;
while((cin>>m),m)
{
cin>>n;
short i,j,temp,count;
for(i=;i<m;i++)
for(j=;j<n;j++)
cin>>arr[i][j];
for(i=;i<m;i++)
for(j=;j<n;j++)
{
cin>>temp;
arr[i][j]+=temp;
}
i = j = temp = count = ;
for(i=; i<m; i++)
{
temp = ;
for(j=; j<n; j++)
temp += arr[i][j];
if(!temp)count++;
}
for(j=; j<n; j++)
{
temp = ;
for(i=; i<m; i++)
temp += arr[i][j];
if(!temp)count++;
}
cout<<count<<endl;
}
}
_jobdu_1001的更多相关文章
随机推荐
- css用标签选择器在本页写样式
<title>静夜思</title><style type="text/css">p{ color:#ff0000; font-size:2 ...
- POJ 1017
http://poj.org/problem?id=1017 题意就是有6种规格的物品,给你一些不同规格的物品,要求你装在盒子里,盒子是固定尺寸的也就是6*6,而物品有1*1,2*2,3*3,4*4, ...
- IDEA 14快捷键
1.ctrl+alt+左箭头.右箭头:返回到上次浏览的代码处(相当于Eclipse的alt+左右箭头) 编辑类: Ctrl+Space 基本代码实例(类.方法.变量) Ctrl + Shift + S ...
- Java for LeetCode 054 Spiral Matrix
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral or ...
- July 26th, Week 31st Tuesday, 2016
The best preparation for tomorrow is doing your best today. 对明天最好的准备就是今天做到最好. The road toward tomorr ...
- fedora 添加其他操作系统到 GRUB 2 菜单
# yum install os-prober # grub2-mkconfig -o /boot/grub2/grub.cfg
- duapp获取mysql用户名密码等等……
duapp呵呵,又是云!比起新浪,这个免费.下面是:(你懂的) <?php/*数据库名称写自己创建的*/$dbname = 'rjKagJvksJdyUKfyPfjY'; /*从环境变量里取出数 ...
- cocos2dx创建sprite的多种方法
方法一 最常用,也是最简单的一种方法 CCSprite *bg=CCSprite::create(,,,)); bg->setAnchorPoint(ccp(,)); bg->setPos ...
- js 完全分离 window.onload=
js 完全分离 window.onload= <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ...
- poj 3928 树状数组
题目中只n个人,每个人有一个ID和一个技能值,一场比赛需要两个选手和一个裁判,只有当裁判的ID和技能值都在两个选手之间的时候才能进行一场比赛,现在问一共能组织多少场比赛. 由于排完序之后,先插入的一定 ...