#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int i, j; int h, w; vectors; double dx, dy; vector>mat(105, vector(105, false)); cin >> h >> w; int x1, y1, x2, y2; for (i = 0; i < h; i++) { string str; cin >> str; s.push_back(str); } bool flag = false; for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (s[i][j] == '*') { if (flag == false) { x1 = j; y1 = i; flag = true; } else { x2 = j; y2 = i; break; } } } } mat[y1][x1] = true; mat[y2][x2] = true; if (x1 == x2) { for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (j == x1) { mat[i][j] = true; } } } } else if (y1 == y2) { for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (i == y1) { mat[i][j] = true; } } } } else if (x2 > x1) { //右下がり dx = (double)(x2 - x1) / (double)abs(y2 - y1); //if (y2 > y1) { double xx = x1; for (i = y1 - 1; i >= 0; i--) { xx -= dx; int dox = floor(xx); int upx = ceil(xx); //if (dox < 0) break; if (dox >= 0) { mat[i][dox] = true; } if (upx >= 0) { mat[i][upx] = true; } } xx = x1; for (i = y1 + 1; i < y2; i++) { xx += dx; int dox = floor(xx); int upx = ceil(xx); //if (upx >= w) break; if (dox < w) { mat[i][dox] = true; } if (upx < w) { mat[i][upx] = true; } } xx = x2; for (i = y2 + 1; i < h; i++) { xx += dx; int dox = floor(xx); int upx = ceil(xx); //if (upx >= w) break; if (dox < w) { mat[i][dox] = true; } if (upx < w) { mat[i][upx] = true; } } //} } else if (x2 < x1) { //右上がり dx = (double)(x1 - x2) / (double)abs(y1 - y2); //if (y2 > y1) { double xx = x1; for (i = y1 - 1; i >= 0; i--) { xx += dx; int dox = floor(xx); int upx = ceil(xx); //if (upx >= w) break; if (dox < w) { mat[i][dox] = true; } if (upx < w) { mat[i][upx] = true; } } xx = x1; for (i = y1 + 1; i < y2; i++) { xx -= dx; int dox = floor(xx); int upx = ceil(xx); if (dox >= 0) { mat[i][dox] = true; } if (upx >= 0) { mat[i][upx] = true; } } xx = x2; for (i = y2 + 1; i < h; i++) { xx -= dx; int dox = floor(xx); int upx = ceil(xx); //if (dox < 0) break; if (dox >= 0) { mat[i][dox] = true; } if (upx >= 0) { mat[i][upx] = true; } } //} } /* else if (x2 > x1) { dx = (double)(x2 - x1) / (double)abs(y2 - y1); if (y2 > y1) { //右斜め下がり double xx = x1; for (i = y1 - 1; i >= 0; i--) { xx -= dx; int dox = floor(xx); int upx = ceil(xx); if (dox < 0) break; mat[i][dox] = true; mat[i][upx] = true; } xx = x1; for (i = y1 + 1; i < y2; i++) { xx += dx; int dox = floor(xx); int upx = ceil(xx); if (upx >= w) break; mat[i][dox] = true; mat[i][upx] = true; } xx = x2; for (i = y2 + 1; i < h; i++) { xx += dx; int dox = floor(xx); int upx = ceil(xx); if (upx >= w) break; mat[i][dox] = true; mat[i][upx] = true; } } else if (y2 < y1) { //右上がり直線 double xx = x1; for (i = y1 - 1; i >= 0; i--) { xx += dx; int dox = floor(xx); int upx = ceil(xx); if (upx >= w) break; mat[i][dox] = true; mat[i][upx] = true; } xx = x1; for (i = y1 + 1; i < y2; i++) { xx -= dx; int dox = floor(xx); int upx = ceil(xx); if (dox < 0) break; mat[i][dox] = true; mat[i][upx] = true; } xx = x2; for (i = y2 + 1; i < h; i++) { xx -= dx; int dox = floor(xx); int upx = ceil(xx); if (dox < 0) break; mat[i][dox] = true; mat[i][upx] = true; } } } else if (x2 < x1) { dx = (double)(x1 - x2) / (double)abs(y1 - y2); if (y2 < y1) { //右下がり double xx = x2; for (i = y2 - 1; i >= 0; i--) { xx -= dx; int dox = floor(xx); int upx = ceil(xx); if (dox < 0) break; mat[i][dox] = true; mat[i][upx] = true; } xx = x2; for (i = y2 + 1; i < y1; i++) { xx += dx; int dox = floor(xx); int upx = ceil(xx); if (upx >= w) break; mat[i][dox] = true; mat[i][upx] = true; } xx = x1; for (i = y1 + 1; i < h; i++) { xx += dx; int dox = floor(xx); int upx = ceil(xx); if (upx >= w) break; mat[i][dox] = true; mat[i][upx] = true; } } else if (y2 > y1) { //右上がり直線 double xx = x2; for (i = y1 - 1; i >= 0; i--) { xx += dx; int dox = floor(xx); int upx = ceil(xx); if (upx >= w) break; mat[i][dox] = true; mat[i][upx] = true; } xx = x1; for (i = y1 + 1; i < y2; i++) { xx -= dx; int dox = floor(xx); int upx = ceil(xx); if (dox < 0) break; mat[i][dox] = true; mat[i][upx] = true; } xx = x2; for (i = y2 + 1; i < h; i++) { xx -= dx; int dox = floor(xx); int upx = ceil(xx); if (dox < 0) break; mat[i][dox] = true; mat[i][upx] = true; } } } */ int x3, y3; bool flag2 = false; for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (mat[i][j] == false) { x3 = j; y3 = i; flag2 = true; break; } } if (flag2 == true) break; } cout << endl; for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (i == y3 && j == x3) { cout << "*"; continue; } else { cout << s[i][j]; } } cout << endl; } /* for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (mat[i][j] == true) { cout << 1; } else { cout << 0; } } cout << endl; } */ getchar(); getchar(); return 0; }