scanf("%c",&a[i][j]); and scanf("%s",a[i]);#includeint w,h;char a[21][21];int B(int i,int j){if(i=w||j=h)return 0;if(a[i][j]=='#')return 0;else{a[i][j]='#';return 1+B(i-1,j)+B(i+1,j)+B(i,j+1)+B(i,j-1);}}int main(){char c;while(~scanf("%d %d",&h,&w)&&
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/29 11:47:51
scanf("%c",&a[i][j]); and scanf("%s",a[i]);#includeint w,h;char a[21][21];int B(int i,int j){if(i=w||j=h)return 0;if(a[i][j]=='#')return 0;else{a[i][j]='#';return 1+B(i-1,j)+B(i+1,j)+B(i,j+1)+B(i,j-1);}}int main(){char c;while(~scanf("%d %d",&h,&w)&&
scanf("%c",&a[i][j]); and scanf("%s",a[i]);
#include
int w,h;
char a[21][21];
int B(int i,int j){
if(i=w||j=h)return 0;
if(a[i][j]=='#')return 0;
else{
a[i][j]='#';
return 1+B(i-1,j)+B(i+1,j)+B(i,j+1)+B(i,j-1);
}
}
int main(){
char c;
while(~scanf("%d %d",&h,&w)&&w>0&&h>0){
for(int i=0;i
scanf("%c",&a[i][j]); and scanf("%s",a[i]);#includeint w,h;char a[21][21];int B(int i,int j){if(i=w||j=h)return 0;if(a[i][j]=='#')return 0;else{a[i][j]='#';return 1+B(i-1,j)+B(i+1,j)+B(i,j+1)+B(i,j-1);}}int main(){char c;while(~scanf("%d %d",&h,&w)&&
换行\n也是一个字符,一个一个字符读入的时候就把换行也读进去了,而以字符串读入的时候是遇到\n就停止读入了.我当时就犯了同样的错误