#include char pole[10000]; int X, Y; void line(int x1, int y1, int x2, int y2) { int dx = x2 - x1, dy = y2 - y1, px, py; if (dx > 0) px = 1; else if (dx < 0) px = -1; else px = 0; if (dy > 0) py = 1; else if (dy < 0) py = -1; else py = 0; do { if (px != 0 && py == 0) { if (pole[X * y1 + x1] != ' ') { if (pole[X * y1 + x1] == '|' || pole[X * y1 + x1] == '+') pole[X * y1 + x1] = '+'; else if (pole[X * y1 + x1] != '-') pole[X * y1 + x1] = '*'; } else pole[X * y1 + x1] = '-'; } else if ((px == 1 && py == 1) || (px == -1 && py == -1)) { if (pole[X * y1 + x1] != ' ') { if (pole[X * y1 + x1] == '/' || pole[X * y1 + x1] == 'x') pole[X * y1 + x1] = 'x'; else if (pole[X * y1 + x1] != '\\') pole[X * y1 + x1] = '*'; } else pole[X * y1 + x1] = '\\'; } else if (px == 0 && py != 0) { if (pole[X * y1 + x1] != ' ') { if (pole[X * y1 + x1] == '-' || pole[X * y1 + x1] == '+') pole[X * y1 + x1] = '+'; else if (pole[X * y1 + x1] != '|') pole[X * y1 + x1] = '*'; } else pole[X * y1 + x1] = '|'; } else { if (pole[X * y1 + x1] != ' ') { if (pole[X * y1 + x1] == '\\' || pole[X * y1 + x1] == 'x') pole[X * y1 + x1] = 'x'; else if (pole[X * y1 + x1] != '/') pole[X * y1 + x1] = '*'; } else pole[X * y1 + x1] = '/'; } x1 += px; y1 += py; } while (x1 != x2 || y1 != y2); } void text(int x, int y, char *znaky) { int j = 0; while (x + j < X && j < strlen(znaky)) { if (pole[X * y + x + j] != ' ' && pole[X * y + x + j] != znaky[j]) pole[X * y + x + j] = '*'; else pole[X * y + x + j] = znaky[j]; j++; } } void clear(int x1, int y1, int x2, int y2) { int p; if (x1 > x2) { p = x1; x1 = x2; x2 = p; } if (y1 > y2) { p = y1; y1 = y2; x2 = p; } for (int j = y1; j <= y2; j++) for (int i = x1; i <= x2; i++) pole[j * X + i] = ' '; } void print() { int i; printf("+"); for (i = 0; i < X; i++) printf("-"); printf("+\n"); for (int j = 0; j < Y; j++) { printf("|"); for (i = 0; i < X; i++) printf("%c", pole[X * j + i]); printf("|\n"); } printf("+"); for (i = 0; i < X; i++) printf("-"); printf("+\n\n"); } void point(int x, int y) { if (pole[X * y + x] != ' ' && pole[X * y + x] != 'o') pole[X * y + x] = '*'; else pole[X * y + x] = 'o'; } int main() { char co[10], retazec[500]; int x1, y1, x2, y2; scanf("%d%d", &X, &Y); while (X != 0 && Y != 0) { clear(0, 0, X -1, Y -1); while (1) { scanf("%s", co); if (!strcmp(co, "POINT")) { scanf("%d%d", &x1, &y1); point(x1 -1, y1 -1); } else if (!strcmp(co, "LINE")) { scanf("%d%d%d%d", &x1, &y1, &x2, &y2); line(x1 -1, y1 -1, x2 -1, y2 -1); } else if (!strcmp(co, "TEXT")) { scanf("%d%d%s", &x1, &y1, retazec); text(x1 -1, y1 -1, retazec); } else if (!strcmp(co, "CLEAR")) { scanf("%d%d%d%d", &x1, &y1, &x2, &y2); clear(x1 -1, y1 -1, x2 -1, y2 -1); } else { print(); break; } } scanf("%d%d", &X, &Y); } return 0; }