#include <iostream>using namespace std; #define N 10#define M 12//The first step is to set the current place to '. ', followed by checking all the other places to see if it meets the requirements, And make a recursive call to void Dfs (int x,int y,char (&field) [n][m]) {field[x][y] = '. '; for (int i =-1, i < 2; ++i) {for (int j =-1; j < 2; ++j) {int nx=x+i,ny=y+j;if (0<=NX && NX <n &&A mp 0<=ny && ny<m && (field[nx][ny] = = ' W ') {DFS (Nx,ny,field);}}}} int main (int argc, char const *argv[]) {char Field[n][m] = {{' W ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', ' w ', '. '},{'. ' ' W ', ' W ', '. ', '. ', '. ', '. ', '. ', ' W ', ' W ', ' W '},{'. ', '. ', '. ', '. ', ' W ', ' W ', '. ', '. ', '. ', ' W ', ' W ', '. '},{'. ', '. ', '. ', '. ', '. ' , '. ', '. ', '. ', '. ', ' W ', '. ', '. '},{'. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', ' . ', '. ', '. ', ' w ', '. '},{' W ', ' W ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', ' W ', ' W ', '. '},{', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ' , '. ', ' W '},{' W ', ' W ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', ' w ', '. '},{', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. ', '. '} ; int res = 0;for (int i = 0; i < N; ++i) {for (int j = 0; J < M; ++J) {if (field[i][j]== ' W ') {DFS (i,j,field); res++;}}} cout<<res<<endl;cout<< "GFs is over!" <<endl;return 0;}