-
10952 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.PS/백준 2022. 2. 17. 21:42
입력은 여러 개의 테스트 케이스로 이루어져 있다.
각 테스트 케이스는 한 줄로 이루어져 있으며, 각 줄에 A와 B가 주어진다. (0 < A, B < 10)
입력의 마지막에는 0 두 개가 들어온다.
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader buf = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); String str = ""; while(!"0 0".equals((str = buf.readLine()))) { String[] arr = str.split(" "); sb.append(Integer.parseInt(arr[0]) + Integer.parseInt(arr[1])); sb.append("\n"); } System.out.println(sb); } }
'PS > 백준' 카테고리의 다른 글
11021 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. (0) 2022.02.21 10953 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. (0) 2022.02.18 10951 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. (0) 2022.02.16 10950 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. (0) 2022.02.15 2558 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.(줄 바꿔서 입력) (0) 2022.02.14