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 |
1562过了,这题自己测试很多数据都对,但是WA,帮我看下吧~#include <stdio.h> void lakecount(char a[100][100],int f[100][100],int i,int j,int n,int m) { if(i>=0&&i<n&&j>=0&&j<m&&f[i][j]==-1&&a[i][j]=='W') { f[i][j]=1; lakecount(a,f,i-1,j-1,n,m); lakecount(a,f,i-1,j,n,m); lakecount(a,f,i-1,j+1,n,m); lakecount(a,f,i,j-1,n,m); lakecount(a,f,i,j+1,n,m); lakecount(a,f,i+1,j-1,n,m); lakecount(a,f,i+1,j,n,m); lakecount(a,f,i+1,j+1,n,m); } } void main() { int num=0,line,col,i,j,flag[100][100]; char str[100][100]; scanf("%d%d",&line,&col); for(i=0;i<line;i++) scanf("%s",str[i]); for(i=0;i<line;i++) for(j=0;j<col;j++) flag[i][j]=-1; for(i=0;i<line;i++) for(j=0;j<col;j++) { if(flag[i][j]==-1&&str[i][j]=='W') { num++; lakecount(str,flag,i,j,line,col); } } printf("%d\n",num); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator