문제:
https://www.acmicpc.net/problem/10951
10951번: A+B - 4
두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.
www.acmicpc.net
코드:
import java.util.*;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int result =0;
while(sc.hasNext()) {
int num1 = sc.nextInt();
int num2 = sc.nextInt();
result = num1+num2;
System.out.println(result);
}
}
}
EOF( End of File )의 관한 문제
EOF란 데이터 소스로부터 더이상 읽을 수 있는 데이터가 없음을 의미한다.
Scanner sc = new Scanner(System.in);
while(sc.hasNextLine()){
sc.nextLine();
}
while(sc.hasNext()){
sc.next();
}
위와 같이 사용
이와 관련된 포스팅
https://gre-eny.tistory.com/307
[Java] EOF(End Of File) 처리하기
EOF(End Of File) EOF(End Of File) 은 데이터 소스로부터 더 이상 읽을 수 있는 데이터가 없음을 의미한다. Scanner 와 BufferedReader 두 클래스의 EOF 처리 를 알아보자. Scanner 보다 BufferedReader 가 성능..
gre-eny.tistory.com
'Java > 백준' 카테고리의 다른 글
[2577] 숫자의 개수 (0) | 2022.06.23 |
---|---|
[1110] 더하기 사이클 (0) | 2022.06.21 |
[2439] 별 찍기-2 (1) | 2022.06.21 |
[2480] 주사위 세 개 (0) | 2022.06.21 |
[2884] 알람 시계 (0) | 2022.06.21 |