zoukankan      html  css  js  c++  java
  • Read and Blank

    #include"stdio.h"
    #include"string.h"
    int map[25][25],des[25][25],n,m,sx,sy;
    void  DFS(int y,int x)
    {
        if(map[y][x]=='#'||des[y][x]||y>n||x>m)
           return  ;
         des[y][x]=1;
         DFS(y-1,x);
         DFS(y+1,x);
         DFS(y,x-1);
         DFS(y,x+1);      
    }
    int main()
    {
       while(scanf("%d%d*c",&m,&n),n||m)
       {
           for(int i=0;i<25;++i)
             for(int j=0;j<25;j++)
               map[i][j]='#',des[i][j]=0;
             for(int i=1;i<=n;++i)
             {
                for(int j=1;j<=m;++j)
                {
                   scanf("%c",&map[i][j]);
                   if(map[i][j]=='0')
                      sy=i,sx=j;       
                }       
               getchar();
             }                                
           DFS(sy,sx);
           int c=0,i,j;
           for(i=1;i<=n;++i)
             for(j=1;j<=m;++j)
                if(des[i][j])
                 ++c;
           printf("%d\n",c);
       }   
        return 0;
    }

  • 相关阅读:
    HDU-1272-小希的迷宫(并查集)
    HDU-1084-What Is Your Grade?
    一个好的函数(gcd)求最小公约数
    HDU-1228-A + B
    HDU-1029-Ignatius and the Princess IV
    自控力》读后感·一
    HDU-2058-The sum problem(数学题技巧型)
    HDU-1430-素数回文
    sftp
    802. 区间和
  • 原文地址:https://www.cnblogs.com/QQbai/p/2135209.html
Copyright © 2011-2022 走看看