Hdu 1241 Oil Deposits

Source: Internet
Author: User

Water problems, to find the number of connected components, deep search can be, the reason why this water is also written down, because the sample a set of wrong data I debugged for one hours, wasted a lot of energy and time. The last set of data has one more space after two 5:

I use GetChar to receive characters, so because it this reason more out of the space so that the characters are all chaotic, debugging output has a strange result, have to spit trough Hangzhou electric You too pit, although not the first time, before you put the row and column of the input order deliberately reverse, Now again here to leave a so disgusting pit, is it necessary to card these non-algorithmic and programming things?

1#include <cstdio>2#include <cstring>3 4 Chars[102][102];5 intdir[2][8]= {{-1,-1,-1,0,0,1,1,1},{-1,0,1,-1,1,-1,0,1}};6 7 voidDfsintIintj) {8     if(s[i][j]=='*')return ;9s[i][j]='*';Ten      for(intk=0; k<8; ++k) { One         intDi= i+dir[0][k], dj= j+dir[1][k]; A         if(s[di][dj]=='@') DFS (DI,DJ); -     } - } the  - intMain () { -     intn,m,i,j; -      while(~SCANF ("%d%d",&n,&m), N) { + GetChar (); -memset (s),'*',sizeof(s)); +          for(i=1; i<=n; ++I,getchar ()) A              for(j=1; j<=m; ++j) ats[i][j]=GetChar (); -         intans=0; -          for(i=1; i<=n; ++i) -              for(j=1; j<=m; ++j) -                 if(s[i][j]=='@'){ - DFS (I,J); in++ans; -                 } toprintf"%d\n", ans); +     } -     return 0; the}

Hdu 1241 Oil Deposits

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.