10871번 - X보다 작은 수
이클립스에서 실행했을 때 결과가 잘 나왔는데 왜 런타임 에러가 나왔는 지 모르겠습니다.
런타임 에러면 소스가 틀렸나 해서 몇 시간이고 계속 쳐다보고 고치려 해보았지만 도무지 모르겠습니다.
public class Main{
public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N, X; N = sc.nextInt(); X = sc.nextInt(); sc.close();
Scanner scA = new Scanner(System.in); int[] A = null; A = new int[N]; for(int i=0;i<N;i++){ A[i] = scA.nextInt(); if(A[i]<X){ System.out.printf("%d ", A[i]); scA.close(); } }}
메인 함수에 대한 닫는 괄호가 없는 것 같아요!
중괄호 말씀하시는 거라면, 있어요. ~
댓글을 작성하려면 로그인해야 합니다.
fman1335 8년 전
이클립스에서 실행했을 때 결과가 잘 나왔는데 왜 런타임 에러가 나왔는 지 모르겠습니다.
런타임 에러면 소스가 틀렸나 해서 몇 시간이고 계속 쳐다보고 고치려 해보았지만 도무지 모르겠습니다.
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N, X;
N = sc.nextInt();
X = sc.nextInt();
sc.close();
Scanner scA = new Scanner(System.in);
int[] A = null;
A = new int[N];
for(int i=0;i<N;i++){
A[i] = scA.nextInt();
if(A[i]<X){
System.out.printf("%d ", A[i]);
scA.close();
}
}
}