baekjoon 2738

0_23·2022년 11월 28일
0

[BOJ][Java]

목록 보기
36/55
post-thumbnail

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        StringTokenizer token = new StringTokenizer(br.readLine());
        int N = Integer.parseInt(token.nextToken()), M = Integer.parseInt(token.nextToken());
        int[][] A = new int[N][M], B = new int[N][M];
        for(int n=0; n<N; n++) {
            token = new StringTokenizer(br.readLine());
            for (int m = token.countTokens()-1; m >= 0; m--){
                A[n][m] = Integer.parseInt(token.nextToken());
            }
        }
        for(int n=0; n<N; n++) {
            token = new StringTokenizer(br.readLine());
            for (int m = token.countTokens()-1; m >= 0; m--){
                B[n][m] = Math.abs(A[n][m]) + Math.abs(Integer.parseInt(token.nextToken()));
                bw.write(B[n][m]+" ");
            }
            bw.write("\n");
        }
        bw.flush();
        br.close();
        bw.close();
    }
}

0개의 댓글