当前位置:网站首页>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;
}
}
边栏推荐
- Thinking about the arrangement problem in the backtracking problem (leetcode questions 46 and 47)
- Polestar美股上市:5.5万台交付如何支持得起超200亿美元估值
- Vite project commissioning
- allegro,orcad, net alias,port,off-page connector之间的异同点和如何选取
- Generate directories from web content
- 7-17 crawling worms (break exercise)
- Redis: operation command of string type data
- 小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。
- Jiuyi cloud black free encryption free version source code
- Comprehensive evaluation of good-looking, easy-to-use and powerful handwriting note taking software: notability, goodnotes, marginnote, handwriting, notes writers, collanote, collanote, prodrafts, not
猜你喜欢
Exercise 9-1 time conversion
Exercise 10-1 judge the three digits that meet the conditions
JVM runtime data area
玖逸云黑免费无加密版本源码
Current situation, analysis and prediction of information and innovation industry
QT learning 17 dialog box and its types
泰凌冲刺科创板:拟募资13亿 国家大基金与小米长江是股东
天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪
QT learning 25 layout manager (4)
中感微冲刺科创板:年营收2.4亿净亏1782万 拟募资6亿
随机推荐
中感微冲刺科创板:年营收2.4亿净亏1782万 拟募资6亿
[acnoi2022] guess numbers
Although not necessarily the best, it must be the hardest!
剑指 Offer 28. 对称的二叉树
Redis:Redis的数据结构、key的操作命令
LNMP环境mail函数不能发送邮件解决
7-4 BCD decryption (10 points)
jvm-运行时数据区
Exercise 10-3 recursive implementation of exponential functions
JS shift operators (< <,> > and > > >)
Strategy, tactics (and OKR)
JS first summary
7-20 print 99 formula table (format output)
C language,%d% Difference between 2D%2d%02d
Polestar美股上市:5.5万台交付如何支持得起超200亿美元估值
7-9 find a small ball with a balance
QT learning 22 layout manager (I)
八大排序
GRPC的四种数据流以及案例
必贝特医药冲刺科创板:年营收97万亏损1.37亿 拟募资20亿