#include #include using namespace std; struct Canvas { int _size; char ** ch; ~Canvas() { for(int i = 0;i<_size;i++){ delete ch[i]; } delete[] ch; } Canvas(int s) { _size = s; ch = new char * [s]; for (int i = 0; i < _size; i++) { ch[i] = new char[s]; for(int j = 0; j < _size; j++) ch[i][j] = '.'; } } void drawTree(int x, int y, int height) { this->miniDraw(x-1,y,'_'); this->miniDraw(x+1,y,'_'); this->miniDraw(x,y,'|'); for(int i = 0; i < height; i++) { this->miniDraw(x-1,y+i+1,'/'); this->miniDraw(x,y+i+1,'|'); this->miniDraw(x+1,y+i+1,'\\'); } this->miniDraw(x,y+height+1,'^'); } void drawStump(int x, int y) { this->miniDraw(x,y,'o'); this->miniDraw(x-1,y,'_'); this->miniDraw(x+1,y,'_'); } void miniDraw(int x, int y, char c) { if(x < _size && y < _size && x >= 0 && y >= 0) { ch[x][y] = c; } } void draw() { for(int i = 0; i < _size + 2;i++) { cout << '*'; } cout << endl; for(int i = _size - 1; i>=0;i--) { cout << '*'; for(int j = 0; j < _size; j++) { if((int)ch[j][i] == 0 ) cout << '.'; else cout << ch[j][i]; } cout << '*' << endl; } for(int i = 0; i < _size + 2;i++) { cout << '*'; } cout << endl << endl; } }; int main() { int pocet,velikost,x,y,height; std::ios_base::sync_with_stdio(false); while(true) { cin >> velikost; if(cin.eof()) break; Canvas canvas(velikost); cin >> pocet; for(int i=0; i < pocet; i++) { cin >> height; cin >> x; cin >> y; if(height == 0)canvas.drawStump(x,y); else canvas.drawTree(x,y,height); } canvas.draw(); } return 0; }