Scanner 를 통해 값을 입력 받을때 String 변수로 값을 받아야 엔터키로 다음 줄로 넘어갈수있다.
즉 int형으로 값을 입력받고 엔터를 누르면 오류가 발생한다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.BufferedWriter; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.io.OutputStreamWriter; | |
public class Main{ | |
public static void main(String args[]) throws NumberFormatException, IOException { | |
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | |
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); | |
String x = br.readLine(); | |
int index = x.indexOf(" "); | |
int n1 = Integer.parseInt(x.substring(0, index)); | |
int n2 = Integer.parseInt(x.substring(index+1,x.length())); | |
String y = br.readLine(); | |
String[] a=y.split(" "); | |
for(int i=0; i<n1; i++) { | |
if(n2>Integer.parseInt(a[i])) { | |
System.out.print(a[i]); | |
System.out.print(" "); | |
} | |
} | |
} | |
} | |
'백준 알고리즘 > JAVA' 카테고리의 다른 글
[JAVA 자바] 백준 4344번 (0) | 2018.07.06 |
---|---|
[JAVA 자바] 백준 1546번 (0) | 2018.07.05 |
[JAVA 자바] 백준 10817번 (0) | 2018.07.05 |
[JAVA 자바] 백준 15552번 (0) | 2018.07.04 |
[JAVA] 백준 11721번 (0) | 2018.07.04 |