<단계>
브론즈 5
<문제>
11718번: 그대로 출력하기
입력이 주어진다. 입력은 최대 100줄로 이루어져 있고, 알파벳 소문자, 대문자, 공백, 숫자로만 이루어져 있다. 각 줄은 100글자를 넘지 않으며, 빈 줄은 주어지지 않는다. 또, 각 줄은 공백으로 시
www.acmicpc.net

<코드>
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
while (s.hasNext()) {
String input = s.nextLine();
System.out.println(input);
}
s.close();
}
}
<개념>
(1) 런타임 에러 (NoSuchElement)

//런타임에러 코드
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
for (int i = 0; i < 100; i++) {
String input = s.nextLine();
System.out.println(input);
}
s.close();
}
}
'Baekjoon > 브론즈 5' 카테고리의 다른 글
[백준][JAVA/자바] 11382번: 꼬마 정민 - while 문 써서 해결하는 방법 (0) | 2023.12.19 |
---|---|
[백준][JAVA/자바] 11022번: A+B - 8 (0) | 2022.12.14 |
[백준][JAVA/자바] 11021번: A+B - 7 (0) | 2022.12.12 |
[백준][JAVA/자바] 10952번: A+B - 5 (0) | 2022.12.09 |
[백준][JAVA/자바] 10951번: A+B - 4 (0) | 2022.12.02 |
댓글