| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么WA呢?大牛帮忙看下 谢谢#include"stdio.h"
void main()
{
int i,j,p,q,m,n=0,n0=-1,step,a[2][100],b[2][100];
char map[20][20];
for(;;)
{
scanf("%d %d%*c",&q,&p);
if(p==0 && q==0)break;
else
{ step=0;
for(i=0;i<p;i++)
{for(j=0;j<q;j++)
{scanf("%c",&map[i][j]);
if(map[i][j]=='@'){a[0][0]=i;a[1][0]=j;a[2][0]=0;step=1;}
}
scanf("%*c");
}
for(;;)
{
for(m=0;m<=n;m++)
{i=a[0][m];j=a[1][m];
if(i-1>=0 && map[i-1][j]=='.'){n0++;b[0][n0]=i-1;b[1][n0]=j;map[i-1][j]='@';step++;}
if(i+1<p && map[i+1][j]=='.'){n0++;b[0][n0]=i+1;b[1][n0]=j;map[i+1][j]='@';step++;}
if(j-1>=0 && map[i][j-1]=='.'){n0++;b[0][n0]=i;b[1][n0]=j-1;map[i][j-1]='@';step++;}
if(j+1<q && map[i][j+1]=='.'){n0++;b[0][n0]=i;b[1][n0]=j+1;map[i][j+1]='@';step++;}
}
if(n0==-1){printf("%d\n",step);break;}
else
{n=n0;
for(n0=0;n0<=n;n0++)
{a[0][n0]=b[0][n0];a[1][n0]=b[1][n0];}
n0=-1;
}
}
}
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator