본문 바로가기

알고리즘

[백준] 10952번: A+B - 5 (java, python)

https://www.acmicpc.net/problem/10952

 

10952번: A+B - 5

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

www.acmicpc.net


🗒 풀이

java

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (sc.hasNext()) {
            int a = sc.nextInt();
            int b = sc.nextInt();

            if (a == 0 && b == 0) {
                break;
            }

            System.out.println(a + b);
        }

        sc.close();
    }
}

python

while True:
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        break
    print(a + b)