当前位置:网站首页>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
15
Code :
#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;
}
}
边栏推荐
- PCB中常用快捷键
- 7-24 reduction of the simplest fraction (rolling Division)
- 愉悦资本新双币基金近40亿元完成首次关账
- 7-9 find a small ball with a balance
- Collection of mobile adaptation related articles
- QT learning 24 layout manager (III)
- JS Part III
- FPGA测试方法以Mentor工具为例
- 7-23 currency conversion (using array conversion)
- 虽然不一定最优秀,但一定是最努力的!
猜你喜欢
TS code automatically generates JS
JS input number and standard digit number are compared. The problem of adding 0 to 0
编程语言:类型系统的本质
Redis:字符串类型数据的操作命令
7-9 find a small ball with a balance
npm install卡住与node-npy的各种奇怪报错
Redis:字符串類型數據的操作命令
Configure stylelint
Leetcode(4)——尋找兩個正序數組的中比特數
泰凌冲刺科创板:拟募资13亿 国家大基金与小米长江是股东
随机推荐
Doxorubicin loaded on metal organic framework MIL-88 DOX | folic acid modified uio-66-nh2 doxorubicin loaded [email
Exercise 6-6 use a function to output an integer in reverse order
Redis:字符串類型數據的操作命令
7-10 calculate salary
7-8 overspeed judgment
关于回溯问题中的排列问题的思考(LeetCode46题与47题)
Exercise 10-1 judge the three digits that meet the conditions
JVM garbage collector
jvm-类加载
GRPC的四种数据流以及案例
JS input number and standard digit number are compared. The problem of adding 0 to 0
Page generation QR code
QT learning 23 layout manager (II)
Zabbix添加Calculated items后保存页面成空白
Vite project commissioning
Exercise 7-6 count capital consonants
Redis:Redis的数据结构、key的操作命令
虽然不一定最优秀,但一定是最努力的!
protobuf与grpc
泰凌冲刺科创板:拟募资13亿 国家大基金与小米长江是股东