标签:des style class blog c code
1 #include <stdio.h> 2 #include <stdlib.h> 3 int D,SIGN,Len_X,Len_Y; 4 char Map[100][100]; 5 int Sign[100][100]; 6 7 int Sign_Part(int x,int y) 8 { 9 10 int ii,jj; 11 if(x>=Len_X||x<0||y>=Len_Y||y<0)return 0; 12 if(Map[x][y]==‘#‘)return 0; 13 else Map[x][y]=‘#‘; 14 /*putchar(‘\n‘); 15 for(ii=0;ii<Len_X;ii++) 16 { 17 for(jj=0;jj<Len_Y;jj++) 18 printf("%c",Map[ii][jj]); 19 putchar(‘\n‘); 20 }*/ 21 Sign[x][y]=1; 22 SIGN++; 23 if(Map[x+1][y]!=‘#‘&&x+1<Len_X&&Sign[x+1][y]!=1) 24 { 25 Sign_Part(x+1,y); 26 Map[x+1][y]=‘.‘; 27 } 28 if(Map[x-1][y]!=‘#‘&&x-1>=0&&Sign[x-1][y]!=1) 29 { 30 Sign_Part(x-1,y); 31 Map[x-1][y]=‘.‘; 32 } 33 if(Map[x][y+1]!=‘#‘&&y+1<Len_Y&&Sign[x][y+1]!=1) 34 { 35 Sign_Part(x,y+1); 36 Map[x][y+1]=‘.‘; 37 } 38 if(Map[x][y-1]!=‘#‘&&y-1>=0&&Sign[x][y-1]!=1) 39 { 40 Sign_Part(x,y-1); 41 Map[x][y-1]=‘.‘; 42 } 43 return 0; 44 45 } 46 47 int main() 48 { 49 int i,j,Begin_x,Begin_y; 50 while(scanf("%d%d",&Len_Y,&Len_X)!=EOF) 51 { 52 if(Len_X==0&&Len_Y==0)break; 53 for(i=0;i<Len_X;i++) 54 { 55 getchar(); 56 for(j=0;j<Len_Y;j++) 57 { 58 scanf("%c",&Map[i][j]); 59 if(Map[i][j]==‘@‘) 60 {Begin_x=i;Begin_y=j;} 61 } 62 } 63 SIGN=0; 64 memset(Sign,0,sizeof(Sign)); 65 Sign_Part(Begin_x,Begin_y); 66 printf("%d\n",SIGN); 67 68 } 69 70 return 0; 71 }
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0
45 59 6 13
标签:des style class blog c code
原文地址:http://www.cnblogs.com/LWF5201314614/p/3750333.html