AC代码:
#include <stdio.h>
#include <string.h>
//author:XXYY
int main(){
int n,m,i,j;
char a[110][110],b;
while(~scanf("%d%d",&n,&m)){
memset(a,'-',sizeof(a));
getchar();
for(i=1;i<=n;i++){
for(j=1;j<=m;j++){
scanf("%c",&b);
if(i%2&&j%2){
if(b=='.')
a[i][j]='B';
}
else if(i%2&&j%2==0){
if(b=='.')
a[i][j]='W';
}
else if(i%2==0&&j%2){
if(b=='.')
a[i][j]='W';
}
else if(i%2==0&&j%2==0){
if(b=='.')
a[i][j]='B';
}
}
getchar();
}
for(i=1;i<=n;i++){
for(j=1;j<=m;j++)
printf("%c",a[i][j]);
printf("\n");
}
}
return 0;
}