kqing @ 2018-12-29 00:44:41
{
### a[1][2]=y;
### int head,tail;
head=0;tail=1;
do{
head++;
for( int i=1;i<=4;i++)
{
int x3,y3;
x3=a[head][1]+dx[i];
y3=a[head][2]+dy[i];
if(ju[x3][y3]=='0'&&x3>0&&x3<=n&&y3>0&&y3<=n)
{
tail++;
b[tail]=b[head]+1;
a[tail][1]=x3;
a[tail][2]=y3;
ju[x3][y3]=1;};
if(a[tail][1]==c&&a[tail][2]==e)
{
cout<<b[tail]<<endl;
return 0;
}
}
}while (head<tail);
}
cin>>n;
int i,j,x1,y1,x2,y2;
for(i=1;i<=n;i++)
for(j=1;i<=n;j++)
{
cin>>ju[i][j];
}
cin>>x1>>y1>>x2>>y2;
c=x2;
e=y2;
bfs(x1,y1);
return 0;
}
by _louhc @ 2018-12-29 07:10:41
希望更丰富的展现?使用Markdown
by yi_heng @ 2018-12-29 07:40:23
希望更丰富的展现?使用Markdown