当前位置:网站首页>Find the sum of the elements of each row of the matrix
Find the sum of the elements of each row of the matrix
2022-07-03 14:15:00 【Study hard 867】
This question requires the preparation of procedures , Find a given m×n The sum of the elements of the matrix .
Input format :
The first line of input gives two positive integers m and n(1≤m,n≤6). And then m That's ok , Each line gives n It's an integer , meanwhile
Space off .
Output format :
Each row outputs the sum of the elements of the corresponding matrix row .
sample input :
3 2
6 3
1 -8
3 12
sample output :
9
-7
15Code :
#include <stdio.h>
int main(){
int lie,hang,sum=0;
scanf("%d%d",&hang,&lie);
int a[hang][lie];
int i,j;
for(i=0;i<hang;i++){
for(j=0;j<lie;j++)scanf("%d",&a[i][j]);
}
for(i=0;i<hang;i++){
for(j=0;j<lie;j++){
sum=a[i][j]+sum;
}
printf("%d\n",sum);
sum=0;
}
}
边栏推荐
- QT learning 22 layout manager (I)
- Leetcode (4) - - trouver la médiane de deux tableaux ordonnés positifs
- FPGA测试方法以Mentor工具为例
- 牛客网:过河卒
- JS matrix zero
- Facebook 如何将 Instagram 从 AWS 搬到自己的服务器
- 28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;
- 7-16 find the set of integers that meet the given conditions
- Article content typesetting and code highlighting
- Polestar美股上市:5.5万台交付如何支持得起超200亿美元估值
猜你喜欢

QT learning 19 standard dialog box in QT (top)

QT learning 20 standard dialog box in QT (middle)

QT learning 25 layout manager (4)

FPGA test method takes mentor tool as an example

JS input number and standard digit number are compared. The problem of adding 0 to 0

QT learning 23 layout manager (II)

FPGA测试方法以Mentor工具为例

QT learning 22 layout manager (I)

jvm-对象生命周期

Print. JS -- web page file printing
随机推荐
JVM runtime data area
QT learning 21 standard dialog box in QT (Part 2)
JS new challenges
7-23 currency conversion (using array conversion)
JS continues to explore...
JVM object lifecycle
玖逸云黑免费无加密版本源码
Simulated access
jvm-类加载
Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
Invalid Z-index problem
Formation of mil-100 (FE) coated small molecule aspirin [email protected] (FE) | glycyrrhetinic acid modified metal organ
7-8 overspeed judgment
Print. JS -- web page file printing
Exercise 10-6 recursively find Fabonacci sequence
28: Chapter 3: develop Passport Service: 11: define attributes in the configuration file, and then obtain them in the code;
PCB中常用快捷键
Jiuyi cloud black free encryption free version source code
QT learning 23 layout manager (II)
Uio-66-cooh loaded bendamostine | hydroxyapatite (HA) coated MIL-53 (FE) nanoparticles | baicalin loaded manganese based metal organic skeleton material