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
|
import java.util.Scanner;
public class baekjoon_2738 { // 행렬 덧셈
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int N = scan.nextInt();
int M = scan.nextInt();
// N * M 크기의 행렬 생성
int sum[][] = new int[N][M];
// N * M의 행렬의 각각 원소 값을 두 번씩 입력 받아 더한다.
for(int i=0; i<2; i++) {
for(int j=0; j<N; j++) {
for(int k=0; k<M; k++) {
sum[j][k] += scan.nextInt();
}
}
}
// N * M의 행렬을 출력한다.
for(int i=0; i<N; i++) {
for(int j=0; j<M; j++) {
System.out.printf("%d ", sum[i][j]);
}
System.out.println();
}
}
}
|
cs |
'Algorithm > 백준' 카테고리의 다른 글
백준 1152 (단어의 개수) (0) | 2022.06.19 |
---|---|
백준 2754 (학점 계산) (0) | 2022.06.19 |
백준 2744 (대소문자 바꾸기) (0) | 2022.06.19 |
백준 1271번 (엄청난 부자2) (0) | 2022.06.08 |
백준 1330번 : 두 수 비교하기 (0) | 2022.05.07 |