A+B - 5

hovi·2023년 5월 30일
0

코딩테스트 백준

목록 보기
31/59
시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초256 MB22816311916210141252.084%

문제

두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.

입력

입력은 여러 개의 테스트 케이스로 이루어져 있다.

각 테스트 케이스는 한 줄로 이루어져 있으며, 각 줄에 A와 B가 주어진다. (0 < A, B < 10)

입력의 마지막에는 0 두 개가 들어온다.

출력

각 테스트 케이스마다 A+B를 출력한다.

예제 입력 1

1 1
2 3
3 4
9 8
5 2
0 0

예제 출력 1

2
5
7
17
7

풀이

package A더하기B빼기5;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a;
        int b;
        int n = 0;
        ArrayList<Integer> arr = new ArrayList<>();
        while (true) {
            a = sc.nextInt();
            b = sc.nextInt();
            if (a == 0 && b == 0) break;
            arr.add(a+b);

        }
        for (int e : arr) System.out.println(e);
    }
}
profile
풀스택 예비 개발자

0개의 댓글