백준 단계별

[Java] 백준 10951: A+B - 4

pullwall 2023. 1. 5. 13:39
728x90
import java.util.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNextInt()) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			System.out.println(a+b);
		}
	}
}

Scanner의 hasNextInt 메소드를 이용하여 더이상 입력받을 데이터가 없으면 종료하게끔 문제를 해결하였다.

728x90