void flood(int x, int y, int new_color, int old_color) { if (x>=0 && x<10 && y>=0 && y<10) if (image[x][y] == old_color) { image[x][y] = new_color; // 寫成一個迴圈 for (int i=0; i<4; i++) { static int dx[4] = {1, -1, 0, 0}; static int dy[4] = {0, 0, 1, -1}; flood(x + dx[i], y + dy[i], new_color, old_color); } } }