ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
int wb, coordinate[2];
string str[10], temp;
char ch[2] = {'b', 'w'};
for(int i = 0; i < 8; i++)cin>>str[i];
cin>>wb>>temp;
coordinate[0] =temp[1]-'1'; coordinate[1] = temp[0] - 'A';
str[coordinate[0]][coordinate[1]]=ch[wb];
for(int i = -1; i <= 1; i++){
for(int j =-1; j <= 1; j++){
if(!i&&!j)continue;
int x = coordinate[1]+j, y = coordinate[0]+i, count = 0;
while(1){//cout<<y<<" "<<x<<" "<<str[y][x]<<endl;
if(y<0||y>=8||x<0||x>=8)break;
count++;
if(str[y][x] == ch[wb]){
for(int k=1; k< count; k++)
str[coordinate[0]+i*k][coordinate[1]+j*k] = ch[wb];
break;
}else if(str[y][x]=='-')break;
y+=i;x+=j;
}//cout<<endl;
}
}
for(int i = 0; i < 8; i++)cout<<str[i]<<endl;
return 0;
}