자바 스캐너사용에서 런타임에러가나는데 소스좀 봐주세요(오류부분 표시함) gugama 안녕하세요,picnic 문제 풀고있는데요 RTE라고 계속 떠서 한줄씩 주석처리하면서 제출해본결과 이 글에서 29라인에 sc.nextLine()에서 오류가 나네요 로컬에선 물론 문제가 없고 오류가 나는게 이해가안되서.. 질문드립니다 import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static int result=0; public static void main(String args[]) throws IOException{ int caseNum=0; int row=0; String temp=""; Scanner sc = new Scanner(System.in); caseNum=Integer.parseInt(sc.nextLine()); List<ArrayList<ArrayList<Character>>> boards=new ArrayList<ArrayList<ArrayList<Character>>>(); for(int i=0;i<caseNum;i++) { boards.add(new ArrayList<ArrayList<Character>>()); temp=sc.nextLine(); row=Integer.parseInt(temp.split(" ")[0]); for(int j=0;j<row;j++) { boards.get(i).add(new ArrayList<Character>()); temp=sc.nextLine();//오류발생부분 for(int k=0;k<temp.length();k++){ boards.get(i).get(j).add(temp.charAt(k)); } } } for(int i=0;i<caseNum;i++) { solver(boards.get(i),boards.get(i).size(),boards.get(i).get(0).size(),0); System.out.println(result); result=0; } sc.close(); return; } public static void solver(ArrayList<ArrayList<Character>> board,int row,int col, int depth) { //왼쪽 방향으로 진행, 끝에 도달하면 아래행으로 넘어감 for(int i=0;i<row;i++) { for(int j=0;j<col;j++) { //빈칸이 처음 발견되는 곳에서 시작 if(board.get(i).get(j)=='.') { //ㄱ자 모양 벽돌을 놓을수 있는 경우의 수는 총 다섯가지, 가능한 경우에 재귀호출, return될 경우 벽돌을 리셋 if(i+1<row&&j+1<col&&board.get(i).get(j+1)=='.'&&board.get(i+1).get(j)=='.') { board.get(i).set(j,'#'); board.get(i).set(j+1,'#'); board.get(i+1).set(j,'#'); solver(board,row,col,depth+1); board.get(i).set(j,'.'); board.get(i).set(j+1,'.'); board.get(i+1).set(j,'.'); } if(i+1<row&&j+1<col&&board.get(i).get(j+1)=='.'&&board.get(i+1).get(j+1)=='.') { board.get(i).set(j,'#'); board.get(i).set(j+1,'#'); board.get(i+1).set(j+1,'#'); solver(board,row,col,depth+1); board.get(i).set(j,'.'); board.get(i).set(j+1,'.'); board.get(i+1).set(j+1,'.'); } if(i+1<row&&j+1<col&&board.get(i+1).get(j+1)=='.'&&board.get(i+1).get(j)=='.') { board.get(i).set(j,'#'); board.get(i+1).set(j,'#'); board.get(i+1).set(j+1,'#'); solver(board,row,col,depth+1); board.get(i).set(j,'.'); board.get(i+1).set(j,'.'); board.get(i+1).set(j+1,'.'); } if(i-1>=0&&j+1<col&&board.get(i).get(j+1)=='.'&&board.get(i-1).get(j+1)=='.') { board.get(i).set(j,'#'); board.get(i).set(j+1,'#'); board.get(i-1).set(j+1,'#'); solver(board,row,col,depth+1); board.get(i).set(j,'.'); board.get(i).set(j+1,'.'); board.get(i-1).set(j+1,'.'); } if(i+1<row&&j-1>=0&&board.get(i+1).get(j-1)=='.'&&board.get(i+1).get(j)=='.') { board.get(i).set(j,'#'); board.get(i+1).set(j-1,'#'); board.get(i+1).set(j,'#'); solver(board,row,col,depth+1); board.get(i).set(j,'.'); board.get(i+1).set(j-1,'.'); board.get(i+1).set(j,'.'); } return; } } } //최초에 모두 막힌벽돌이었을 경우 성공으로 처리되는 예외를 방지하기 위함 if(depth!=0) result=result+1; return; } } 13년 전
1개의 댓글이 있습니다. 일루 일단, 글 올리실때는 마크업 문법 참조하셔서 ~~~ java / ~~~ 식으로 표시를 부탁드립니다. 13년 전 link 정회원 권한이 있어야 커멘트를 다실 수 있습니다. 정회원이 되시려면 온라인 저지에서 5문제 이상을 푸시고, 가입 후 7일 이상이 지나셔야 합니다. 현재 문제를 푸셨습니다.
gugama
안녕하세요,picnic 문제 풀고있는데요
RTE라고 계속 떠서 한줄씩 주석처리하면서 제출해본결과
이 글에서 29라인에 sc.nextLine()에서 오류가 나네요
로컬에선 물론 문제가 없고 오류가 나는게 이해가안되서..
질문드립니다
13년 전