At the beginning, I wrote something in Java. Thank you for your advice.
1. the handler is located in Java. util. *.
2. Java's string class is not like the string in C ++. Data input and hash are affected.
In general, it is quite adaptive.
Import Java. util. *; <br/> public class main {<br/>/** <br/> * @ Param ARGs <br/> */<br/> static int N, m; <br/> static final int maxn = 101; <br/> static char map [] [] = new char [maxn] [maxn]; <br/> static int dir [] [] = {0, 1}, {0,-1}, {-1, 0}, {1, 0 }, {1, 1}, {-1,-1}, {-1, 1}, {1,-1 }}; </P> <p> static Boolean inmap (int r, int C) {<br/> return r> = 0 & C> = 0 & R <n & C <m; <br/>}</P> <p> static void DFS (int r, int c) {<br/> map [r] [c] = '*'; <br/> int _ r, _ C, I; <br/> for (I = 0; I <8; I ++) {<br/> _ r = R + dir [I] [0]; <br/> _ C = C + dir [I] [1]; <br/> If (inmap (_ r, _ C) & map [_ r] [_ c] = '@') {<br/> DFS (_ r, _ C ); <br/>}</P> <p> Public static void main (string [] ARGs) {<br/> // todo auto-generated method stub <br/> int I, j, CNT; <br/> string a = new string (); <br/> memory in = new memory (system. in); <br/> while (true) {<br/> N = in. nextint (); <br/> M = in. nextint (); <br/> If (n = 0 & M = 0) break; <br/> for (I = 0; I <N; I ++) {<br/> A = in. next (); <br/> map [I] =. tochararray (); <br/>}< br/> for (CNT = I = 0; I <n; I ++) {<br/> for (j = 0; j <m; j ++) {<br/> If (Map [I] [J] = '@') {<br/> CNT ++; <br/> DFS (I, j); <br/>}< br/> system. out. println (CNT); <br/>}</P> <p >}< br/>