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 |
拜托大神帮我除错一下 感恩~~#define max_n 100 #define max_m 100 #include<stdio.h> char map[max_n][max_m+1]; int n,m; void dfs(int nx,int ny){ map[nx][ny] = '.'; for(int dx = -1;dx <= 1;dx++) for(int dy = -1;dy <= 1;dy++){ int nex = nx+dx, ney = ny+dy; if(nex>=0 && nex <m && ney>=0 && ney < n && map[nex][ney] == 'W'){ dfs(nex,ney); } } return; } int main(){ int cnt = 0; scanf("%d%d",&n,&m); for(int i = 0;i<n;i++) scanf("%s",&map[i]); for(int i = 0;i<n;i++) for(int j = 0;j<m;j++){ if(map[j][i] == 'W'){ dfs(j,i); cnt++; } } printf("%d\n",cnt); } 范例测资都有过啊~~~ Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator