-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2738.java
More file actions
40 lines (38 loc) · 1.29 KB
/
2738.java
File metadata and controls
40 lines (38 loc) · 1.29 KB
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
37
38
39
40
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
int m = Integer.parseInt(st.nextToken());
int matrixA[][] = new int[n][m];
int matrixB[][] = new int[n][m];
for(int i=0; i<n; i++){
st = new StringTokenizer(br.readLine());
for(int j=0; j<m; j++){
matrixA[i][j]=Integer.parseInt(st.nextToken());
}
}
for(int i=0; i<n; i++){
st = new StringTokenizer(br.readLine());
for(int j=0; j<m; j++){
matrixB[i][j]=Integer.parseInt(st.nextToken());
}
}
int result[][]=new int[n][m];
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
result[i][j]=matrixA[i][j]+matrixB[i][j];
}
}
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
System.out.print(result[i][j]+" ");
}
System.out.println();
}
}
}