标签:des style class blog c code
2 2 DK HF 3 3 ADC FJK IHE -1 -1
2 3
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 int LenX,LenY,num[55][55],sign[55][55],SIGN; 5 int Map[11][4]={1,1,0,0, 0,1,1,0, 1,0,0,1, 0,0,1,1, 0,1,0,1, 1,0,1,0, 1,1,1,0, 1,1,0,1, 1,0,1,1, 0,1,1,1, 1,1,1,1}; 6 void Deal(int y,int x) 7 { 8 int i,ii,jj; 9 if(sign[y][x]==1)return; 10 if(x<0||y<0||x>=LenX||y>=LenY)return; 11 sign[y][x]=1; 12 if(Map[num[y][x]][0]==1) 13 if((x-1>=0)&&(Map[num[y][x-1]][2]==1))Deal(y,x-1); 14 if(Map[num[y][x]][2]==1) 15 if((x+1<LenX)&&(Map[num[y][x+1]][0]==1))Deal(y,x+1); 16 if(Map[num[y][x]][1]==1) 17 if((y-1>=0)&&(Map[num[y-1][x]][3]==1))Deal(y-1,x); 18 if(Map[num[y][x]][3]==1) 19 if((y+1<LenY)&&(Map[num[y+1][x]][1]==1))Deal(y+1,x); 20 } 21 int main() 22 { 23 int i,x,y,j,ii,jj; 24 char str[55][55]; 25 while(scanf("%d%d",&y,&x)!=EOF) 26 { 27 getchar(); 28 if(x==-1&&y==-1)return; 29 memset(sign,0,sizeof(sign)); 30 memset(num,0,sizeof(num)); 31 LenX=x;LenY=y; 32 for(i=0;i<y;i++) 33 gets(str[i]); 34 for(j=0;j<y;j++) 35 for(i=0;i<x;i++) 36 {num[j][i]=str[j][i]-‘A‘;sign[j][i]=0;} 37 for(j=0,SIGN=0;j<y;j++) 38 for(i=0;i<x;i++) 39 if(sign[j][i]==0) 40 {Deal(j,i);SIGN++;} 41 printf("%d\n",SIGN); 42 } 43 return 0; 44 }
Farm Irrigation,布布扣,bubuko.com
标签:des style class blog c code
原文地址:http://www.cnblogs.com/LWF5201314614/p/3750308.html