local에서 예시와 나온 것과 똑같이 입력하면 답이 맞게 나오는데
여기서 문제를 제출하니 런타임 오류 RTE가 나옵니다. ㅠㅠ;
그 이유를 알고 싶습니다.
~~~java
import java.util.Scanner;
public class Main {
static int location;
private static int answer2(char[][] pans, String input, int x, int y)
{
int ret = 0;
//System.out.println("x=" + x +", y=" + y + ", location=" + location);
if(location
{
++location;
//System.out.println(input.charAt(location));
if(x>0 && y>0) ret = answer2(pans,input,x-1,y-1);
if(x0) ret = answer2(pans,input,x+1,y-1);
if(x
if(x>0 && y
if(x>0) ret = answer2(pans,input,x-1,y);
if(x
if(y>0) ret = answer2(pans,input,x,y-1);
if(y<pans[x].length-1) ret = answer2(pans,input,x,y+1);
}
return location;
}
sdrlurker
local에서 예시와 나온 것과 똑같이 입력하면 답이 맞게 나오는데
여기서 문제를 제출하니 런타임 오류 RTE가 나옵니다. ㅠㅠ;
그 이유를 알고 싶습니다.
~~~java
import java.util.Scanner;
public class Main {
{0) ret = answer2(pans,input,x+1,y-1);
if(x>0 && y
if(x>0) ret = answer2(pans,input,x-1,y);
if(y>0) ret = answer2(pans,input,x,y-1);
static int location;
private static int answer2(char[][] pans, String input, int x, int y)
{
int ret = 0;
//System.out.println("x=" + x +", y=" + y + ", location=" + location);
if(location
++location;
//System.out.println(input.charAt(location));
if(x>0 && y>0) ret = answer2(pans,input,x-1,y-1);
if(x
if(x
if(x
if(y<pans[x].length-1) ret = answer2(pans,input,x,y+1);
}
return location;
}
}
~~~
13년 전