标签:contains void ram problems bottom desc iss elf memory
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0
45 59 6 13
#include<stdio.h> #include<string.h> char map[22][22]; int dd[22][22]; int n,m; void DP(int i,int j,int &res){ if(i<=0||i>n||j<0||j>=m) return ; if(map[i][j]=='#') return; if(dd[i][j]==0&&(map[i][j]=='.'||map[i][j]=='@')) { dd[i][j]=1; res++; DP(i-1,j,res);DP(i+1,j,res); DP(i,j-1,res);DP(i,j+1,res); } } int main(){ while(scanf("%d %d",&m,&n),n||m){ memset(map,0,sizeof(map)); memset(dd,0,sizeof(dd)); int i,j,res,num=0;int tx,ty; for(i=1;i<=n;++i){ scanf("%s",map[i]); } for(i=1;i<=n;++i){ for(j=0;j<m;++j) if(map[i][j]=='@') tx=i,ty=j; } //printf("%d====%d\n",tx,ty);; res=0; DP(tx,ty,res); printf("%d\n",res); } return 0; }
标签:contains void ram problems bottom desc iss elf memory
原文地址:http://www.cnblogs.com/mthoutai/p/7063982.html