1001_A+B for Matrices
来源:互联网 发布:淘宝gxg代购是正品吗 编辑:程序博客网 时间:2024/05/22 01:29
//题目1001:A+B for Matrices//时间限制:1 秒内存限制:32 兆特殊判题:否提交:20447解决:8174//题目描述:// 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 "stdafx.h"#include "stdio.h"#include "string.h"#define MAX 11int a[MAX][MAX];int column[MAX];int row[MAX];int main(){ //freopen("1001_data.in","r",stdin); //freopen("1001_data.out","w",stdout); int n,m,temp,count; while(scanf("%d %d",&m,&n) == 2 && m!=0) { for(int i = 0;i<MAX;i++) { column[i]=1; row[i]=1; } count = 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",&temp); a[i][j] += temp; if(a[i][j]!=0) { row[i] = 0; column[j] = 0; } } count += row[i]; } for(int j = 0;j<n;j++) { count += column[j]; } printf("%d\n",count); } return 0;}
0 0
- 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
- 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
- 题目1001:A+B for Matrices
- 题目1001:A+B for Matrices
- 题目1001:A+B for Matrices
- 题目1001:A+B for Matrices
- Angularjs笔记
- request.getParameter()获取不到数据的问题
- Spring中ClassPathXmlApplicationContext类的简单使用
- 一起学WEB(八) 一个网页练习(一)
- docker
- 1001_A+B for Matrices
- (u)int8_t/(u)int16_t/(u)int32_t/(u)int64_t/(u)intptr_t简介
- 设计模式之十一:策略模式
- c++ unsigned和int类型转换及运算
- 16 款最流行的 JavaScript 框架
- Swagger入门教程
- Java中如何使封装自己的类,建立并使用自己的类库?
- 关于配置华为VLAN划分及实现VLAN间的通信
- 微信小程序开发如何使用npm包--labrador使用