#include #include int X, Y; char pole[80][80]; char str[20]; char ret[10000]; bool strDiag(char a, char b) { if ((a=='/' || a=='\\' || a=='x') && (b=='\\' || b=='/' || b=='x')) return true; else return false; } bool strHoriz(char a, char b) { if ((a=='|' || a=='-' || a=='+')&&(b=='|' || b=='-' || b=='+')) return true; else return false; } void SetChar(int x, int y, char c) { if (x<1 || x>X || y<1 || y>Y) return; char c2 = pole[y][x]; if (!c2) pole[y][x] = c; else { if ( c == c2 ) pole[y][x] = c; else if (strDiag(c,c2)) pole[y][x] = 'x'; else if(strHoriz(c,c2)) pole[y][x] = '+'; else if (!c) pole[y][x] = 0; else pole[y][x] = '*'; } } void DoLine() { int x1, x2, y1, y2; scanf("%i %i %i %i\n",&x1,&y1,&x2,&y2); if ( x1 < x2 ) { if (y1X || y1>Y) break; SetChar(x1,y1,'\\'); } } else if (y1>y2) for( ; x1<=x2; x1++,y1--) SetChar(x1,y1,'/'); else for (; x1<=x2; x1++) SetChar(x1,y1,'-'); } else if (x1 > x2) { if (y1=x2; x1--,y1++) SetChar(x1,y1,'/'); else if (y1>y2) for ( ; x1>=x2; x1--,y1--) SetChar(x1,y1,'\\'); else for ( ; x1>=x2; x1--) SetChar(x1,y1,'-'); } else { if (y1=y2; y1--) SetChar(x1,y1,'|'); } } void DoPoint() { int x,y; scanf("%i %i\n",&x,&y); SetChar(x,y,'o'); } void DoText() { int x,y; scanf("%i %i %s\n",&x,&y,ret); for(int i=0; iX) break; SetChar(x,y,ret[i]); x++; } } void DoClear() { int x1,x2,y1,y2; scanf("%i %i %i %i\n",&x1,&y1,&x2,&y2); if (x1=y2; j--) SetChar(i,j,0); } else { if (y1=x2; i--) for (int j=y1; j<=y2; j++) SetChar(i,j,0); else for (int i=x1; i>=x2; i--) for(int j=y1; j>=y2; j--) SetChar(i,j,0); } } void DoPrint() { for (int i = 1; i<=X; i++) { pole[0][i] = '-'; pole[Y+1][i] = '-'; } for (int i = 1; i<=Y; i++) pole[i][0] = pole[i][X+1] = '|'; pole[0][0] = pole[0][X+1] = pole[Y+1][0] = pole[Y+1][X+1] = '+'; for (int i =0; i<=Y+1; i++){ for (int j=0; j<=X+1; j++) if (pole[i][j]) printf("%c",pole[i][j]); else printf(" "); printf("\n"); } } int main() { scanf("%i %i\n",&X, &Y); while ( X || Y ) { memset(pole,0,80*80); while (1) { scanf("%s",str); if (!strcmp(str,"LINE")) DoLine(); else if (!strcmp(str,"POINT")) DoPoint(); else if (!strcmp(str,"CLEAR")) DoClear(); else if (!strcmp(str,"TEXT")) DoText(); else if (!strcmp(str,"PRINT")) { DoPrint(); break; } } scanf("%li %li ", &X, &Y); } return 0; }