Matrix
In the world of business, data analysis have become more and more important. As a data analyst, your job involves taking a look at a lot of data and figuring out some basic information about it.
In this problem, you will design a programme that outputs the sum of each row and column in a matrix.
Input Specification
The first line will contain two integers \(N, M\) (\(1 < N,M < 200\)), indicating the size of the matrix (\(N\) rows \(M\) columns).
The next \(N\) line will give the value of the matrix. Each row will contain \(M\) integers.
Output Specification
The first line should contain \(N\) integers, indicating the sum of each row in the matrix.
The second line should contain \(M\) integers, indicating the sum of each column in the matrix.
Sample Input
3 2
1 2
3 4
5 6
Sample Output
3 7 11
9 12
Hint (C++)
To read the value of an \(n \times m\) matrix, you can use the following lines of code:
for (int i=0; i<n; i++)
for (int j=0; j<m; j++)
cin >> a[i][j];
Comments