{{{~cpp #include #include using namespace std; bool bitmap1[252][252]; char bitmap[252][252]; char instruction; int x1, x2, y1, y2; int size_x, size_y; char color, temp; char name[255], trash[255]; int i, j; void CreateBitmap() { for(i=0; i<=size_x+1; i++) for(j=0; j<=size_y+1; j++) bitmap[i][j] = '.'; for(i=1; i<=size_x; i++) for(j=1; j<=size_y; j++) bitmap[i][j] = 'O'; } void brush(int x_1, int y_1, int x_2, int y_2, char b_color) { int tempInt; if(x_1>size_x || x_2>size_x || y_1>size_y || y_2>size_y) return; if(x_1>x_2) { tempInt = x_1; x_1 = x_2; x_2 = tempInt; } if(y_1>y_2) { tempInt = y_1; y_1 = y_2; y_2 = tempInt; } for(i=x_1; i<=x_2; i++) for(j=y_1; j<=y_2; j++) bitmap[i][j] = b_color; } void printing() { cout << name << endl; for(j=1; j<=size_y; j++) { for(i=1; i<=size_x; i++) cout << bitmap[i][j]; cout < pointList_X; queue pointList_Y; pointList_X.push(x); pointList_Y.push(y); while(0 != pointList_X.size()) { x = pointList_X.front(); pointList_X.pop(); y = pointList_Y.front(); pointList_Y.pop(); if (bitmap[x][y]!=temp) continue; bitmap[x][y] = b_color; for (j = 0; j < 8; j++) { if(bitmap[x + PLUS_X[j]][y + PLUS_Y[j]]==temp && bitmap1[x + PLUS_X[j]][y + PLUS_Y[j]]) { pointList_X.push(x + PLUS_X[j]); pointList_Y.push(y + PLUS_Y[j]); bitmap1[x + PLUS_X[j]][y + PLUS_Y[j]]=false; } } } } int main() { while(cin>>instruction) { if(instruction=='X') break; if(instruction=='I' || instruction=='C') { if(instruction=='I') cin >> size_x >> size_y; CreateBitmap(); } else if(instruction=='L' || instruction=='V' || instruction=='H' || instruction=='K') { if(instruction=='L') { cin>> x1>>y1>>color; x2=x1; y2=y1; } else if(instruction=='V') { cin>> x1>>y1>>y2>>color; x2=x1; } else if(instruction=='H') { cin >> x1>>x2>>y1>>color; y2=y1; } else cin >>x1>>y1>>x2>>y2>>color; brush(x1,y1,x2,y2,color); } else if(instruction=='F') { cin >>x1>>y1>>color; temp = bitmap[x1][y1]; for(i=0; i> name; printing(); } cin.getline(trash, 254); } return 0; } }}}