当前位置:网站首页>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;
}
}
边栏推荐
猜你喜欢
allegro,orcad, net alias,port,off-page connector之间的异同点和如何选取
玖逸云黑免费无加密版本源码
Leetcode (4) -- find the median of two positively ordered arrays
Exercise 6-6 use a function to output an integer in reverse order
7-15 calculation of PI
[email protected] (FE) | glycyrrhetinic acid modified metal organ"/>
Formation of mil-100 (FE) coated small molecule aspirin [email protected] (FE) | glycyrrhetinic acid modified metal organ
Scroll detection of the navigation bar enables the navigation bar to slide and fix with no content
天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪
7-18 finding the single root of polynomial by dichotomy
QT learning 22 layout manager (I)
随机推荐
Folic acid modified metal organic framework (zif-8) baicalin loaded metal organic framework composite magnetic material (AU- [email
Webpage connection database ~ simple implementation of addition, deletion, modification and query complete code
JS matrix zero
JS shift operators (< <,> > and > > >)
Exercise 10-3 recursive implementation of exponential functions
Onmenusharetimeline custom shared content is invalid, and the title and icon are not displayed
Configure stylelint
FPGA测试方法以Mentor工具为例
牛客网:过河卒
Similarities and differences between Allegro, OrCAD, net alias, port, off page connector and how to select them
Redis: operation command of string type data
Thinking about the arrangement problem in the backtracking problem (leetcode questions 46 and 47)
Exercise 9-3 plane vector addition
天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪
6-9 statistics of single digits (15 points)
7-23 currency conversion (using array conversion)
Exercise 6-1 classify and count the number of characters
Exercise 8-8 moving letters
全局事件总线
Learn to punch in today