문제
두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.
입력
입력은 여러 개의 테스트 케이스로 이루어져 있다.
각 테스트 케이스는 한 줄로 이루어져 있으며, 각 줄에 A와 B가 주어진다. (0 < A, B < 10)
출력
각 테스트 케이스마다 A+B를 출력한다.
예제 입력 1
1 1
2 3
3 4
9 8
5 2
예제 출력 1
2
5
7
17
7
문제 풀이
import java.io.*;
public class 백준_10951번 {
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));
String line;
while((line = br.readLine()) != null) {
String[] input = line.split(" ");
int a = Integer.parseInt(input[0]);
int b = Integer.parseInt(input[1]);
bw.write(a+b + "\\n");
}
bw.flush();
bw.close();
bw.close();
}
}
}
'코딩테스트 > 백준(JAVA)' 카테고리의 다른 글
[백준][JAVA] 10871번. X보다 작은 수 (0) | 2024.05.25 |
---|---|
[백준][JAVA] 10807번. 개수 세기 (0) | 2024.05.25 |
[백준][JAVA] 10952번. A+B - 5 (0) | 2024.05.15 |
[백준][JAVA] 2439번. 별 찍기 -2 (0) | 2024.05.15 |
[백준][JAVA] 2438번. 별 찍기-1 (0) | 2024.05.15 |