原题链接:https://leetcode.com/problems/flood-fill/
vector<vector<int>> floodFill(vector<vector<int>>& image, int sr, int sc, int newColor) {
int m = image.size(), n = image[0].size();
int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
int oldColor = image[sr][sc];
if (oldColor == newColor) return image;
image[sr][sc] = newColor;
for (int i = 0; i < 4; i ++ ) {
int x = sr + dx[i], y = sc + dy[i];
if(x >= 0 && x < m && y >=0 && y < n && image[x][y] == oldColor) {
floodFill(image, sr + dx[i], sc + dy[i], newColor);
}
}
return image;
}