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 |
请输入时nm时中间加上空格,真的,,很坑,,,,真的,,我要制造病毒黑了它系统#include<stdio.h> #include<iostream> using namespace std; const int N = 1000; char a[N][N]; int n, m; void dfs(int i, int j) { a[i][j] = '.'; int x, y, x1, y1; for(x = -1; x<=1; x++) { for(y = -1; y<=1; y++) { x1 = i+x; y1 = j+y; if(x1 >= 0 && x1 <n && y1 < m && 0<= y1 && a[x1][y1] == 'W') dfs(x1, y1); } } } int main() { int i, j, ans = 0; scanf("%d %d", &n, &m); for(i = 0; i<n; i++) { scanf("%s", a[i]); //输入请输入%s, %c有问题 } for(i = 0; i<n; i++) { for(j = 0; j<m; j++) { if(a[i][j] == 'W') { dfs(i, j); ans++; } } } printf("%d\n", ans); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator