#### ssifood1주 전    1

런타임 에러 납니다. 왜그런지 알려주십시요 여러분 하하하하하하하하.

import java.util.*;

class Main{

public static void main(String[]args){
int n,m;
int cnt;
Point st,now;
boolean visit[][];
Queue<Point>q;

Scanner sc= new Scanner(System.in);
n=sc.nextInt();
m=sc.nextInt();
visit= new boolean[n+1][m+1];
st=new Point(1,1);
cnt=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
}//for
}//for

now= new Point(0,0);
q.offer(st);
while(!q.isEmpty()){
now=q.poll();
cnt++;
visit[now.x][now.y]=true;
if(now.x>1 && visit[now.x-1][now.y]==false && ad[now.x-1][now.y]==1 ) q.offer(new Point(now.x-1,now.y));
if(now.x<n && visit[now.x+1][now.y]==false && ad[now.x+1][now.y]==1) q.offer(new Point(now.x+1,now.y));
if(now.y>1 && visit[now.x][now.y-1]==false && ad[now.x][now.y-1]==1) q.offer(new Point(now.x,now.y-1));
if(now.y<m && visit[now.x][now.y+1]==false && ad[now.x][now.y+1]==1) q.offer(new Point(now.x,now.y+1));

if(now.x==n &&now.y==m) break;
}
System.out.print(cnt);

//class~~~~

}//main

static class Point{
int x;
int y;
public Point(int x, int y){
this.x=x;
this.y=y;
}
}
}//MAin

#### zlzmsrhak1주 전

입력을 잘 보시면 각 줄의 숫자가 붙어있습니다. nextInt()로 입력받으면 당연히 안되겠죠

댓글을 작성하려면 로그인해야 합니다.