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 |
到底是哪里错了???试了好几次,真的不会改了!!求教大神,感激不尽#include<stdio.h> int n,m; char k[101][101]; void change(int x,int y) { int dx,dy,nx,ny; for(dx=-1;dx<=1;dx++) { for(dy=-1;dy<=1;dy++) { nx=x+dx; ny=y+dy; if(nx>=0&&nx<n&&ny>=0&&ny<m&&k[nx][ny]=='W') { change(nx,ny); } } } } int main() { //void change(int x,int y); int i,j,s; int n,m; char k[101][101]; scanf("%d%d",&n,&m); for(i=0;i<n;i++) { scanf("%s",k[i]); } s=0; for(i=0;i<n;i++) { for(j=0;j<m;j++) { if(k[i][j]=='W') { s++; change(i,j); } } } printf("%d\n",s); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator