[백준/Java] 10950 : A+B - 3

SEOP·2023년 5월 8일
0
post-thumbnail

import java.io.*;

public 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));

        int T = Integer.parseInt(br.readLine());

        while(T !=0){
            String[] str = br.readLine().split(" ");
            int a= Integer.parseInt(str[0]);
            int b= Integer.parseInt(str[1]);
            bw.write(String.valueOf(a+b) +"\n");
            T-=1;
        }
        bw.flush();
        bw.close();
    }
}

OR

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public 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));

        int T = Integer.parseInt(br.readLine());
        List<Integer> list= new ArrayList<>();

        while(T !=0){
            String[] str = br.readLine().split(" ");
            int a= Integer.parseInt(str[0]);
            int b= Integer.parseInt(str[1]);
            list.add(a+b);
            T-=1;
        }
        for(int i = 0; i< list.size(); i++){
            bw.write(list.get(i)+"\n");
        }
        bw.flush();
        bw.close();
    }
}
profile
응애 나 애기 개발자

0개의 댓글