#include <iostream>
#include <vector>
#include <string>
using namespace std;

int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

vector<string> b(10);

void paint(int y, int x){
    for (int i = 0; i < 4; i++) {
        int ny = y + dy[i];
        int nx = x + dx[i];

        if (0 <= ny && ny < 10 && 0 <= nx && nx < 10 && b[ny][nx] == '_') {
            b[ny][nx] = '*';
            paint(ny, nx);
        }
    }
}

int main() {
    for (int i = 0; i < 10; i++) {
        cin >> b[i];
    }

    int x, y;
    cin >> x >> y;

    if (b[y][x] == '_') {
        b[y][x] = '*';
        paint(y, x);
    }

    for (int i = 0; i < 10; i++) {
        cout << b[i] << '\n';
    }

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: