-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day44.java
36 lines (28 loc) · 968 Bytes
/
Day44.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// MultiDimensional Arrays
// https://www.interviewbit.com/problems/multidimensional-arrays/
import java.lang.*;
import java.util.*;
public class Day44 {
public static void main(String[] args) {
// YOUR CODE GOES HERE
// Please take input and print output to standard input/output (stdin/stdout)
// DO NOT USE ARGUMENTS FOR INPUTS
// E.g. 'Scanner' for input & 'System.out' for output
Scanner scan = new Scanner(System.in);
int m = scan.nextInt();
int n = scan.nextInt();
int[][] arr = new int[m][n];
for(int i = 0; i < m; i++) {
for(int j = 0; j < n; j++) {
arr[i][j] = scan.nextInt();
}
}
for(int i = 0; i < n; i++) {
int sum = 0;
for(int j = 0; j < m; j++) {
sum = sum + arr[j][i];
}
System.out.print(sum + " ");
}
}
}