(Ah ah ah finally made up for today's homework)
Address: http://www.luogu.org/problem/show?pid=1058
Title Description
Obuchi is a smart kid, and he often gives the kids around to write what they think is interesting. Recently, he is going to explain the three-dimensional map to the children, please help him to draw a three-dimensional map.
Obuchi has an area of m*n rectangular area, which has m*n side length of 1 lattice, each lattice stacked with some of the same size of bricks (building blocks of the length and width of 1), Obuchi want to ask you to print out the three-dimensional map of these lattice. We define each block as the following format, and do not do any rollover rotation, only strictly in this form:
Each vertex is represented by 1 plus ' + ', long with 3 "-", wide with 1 "/", high with two "|" Said. Character ' + ', '-', '/', ' | ' The ASCII code is 43,45,47,124, respectively. Character '. ' (ASCII code 46) needs to be used as a background output, that is, the blank part of the stereoscopic map needs to be '. ' To replace. The drawing of a stereoscopic chart is as follows:
If two blocks are adjacent, the diagram is:
If two blocks are adjacent, the diagram is:
If two blocks are adjacent, the diagram is:
In a stereoscopic diagram, the bottom-left corner of the first block (that is, the most bottom block) of the grid (the 1th column of row m) above is defined as the point at the lower-left corner of the entire graph (m,1).
Input/output format
Input format:
The input file drawing.in the first line of useful spaces separated by 2 integers m and n, indicating a m*n lattice (1<=m,n<=50).
The next M-line is a m*n matrix with n spaces separated by a line of integers, where the integer on row J of line I indicates how many bricks are stacked on the sub-column of row J of Line I (1<= the number of bricks on each lattice <=100).
Output format:
Output file Drawing.out contains the title of the three-dimensional graph, is a K-row l column of the string matrix, where K and L represent a minimum of K row L column in order to output three-dimensional map.
Input/Output sample
Input Sample # #:
3 42 2 1 22 2 1 13 2 1 2
Sample # # of output:
......+---+---+...+---+.. +---+ / /|.. / /|. / /|-+---+ |. +---+ |+---+ |/ /| +-| | +| | +---+ |/+---+ |/|| | / /| +/ /|-+ |+---+---+ |/+---+ |/| +| | | +-| | + |/.| | | / | | -| +.. +---+---+---+---+ |/...| | | | | +....| | | | | /.....+---+---+---+---+......
Description
The fourth question of NOIP2008 popularization group
--------------------------------------------your friend split line bacteria are offline---------------------------------------------------------------
After reading this question do not be confused, carefully see "ah so simple original simulation is good"
The first is to draw out, drawing out the problem is that there will be overlapping, how to do? It's good to draw the lowest-priority block first.
It's probably first drawn in the back, in the bottom, on the left.
↑ It is easy to say, you give me casually write a out AH!!!!!!!
So consider a block as a large rectangle.
".. +---+",
"./ /|",
"+---+ |",
"| | +",
"| |/.",
"+---+.."
So that it can be drawn into the matrix.
The next thing to do is to solve the problem of where the picture is, but the XY coordinates are pretty bad (count it!). )
There's nothing wrong (it's weird)
Paste Code
#include <stdio.h>#include<stdlib.h>#include<string.h>Const Char*pic[6]={ ".. +---+", "./ /|", "+---+ |", "| | +", "| |/.", "+---+.."};Char out[404][303];Charpri[304];intGitWuyi][Wuyi];intWriteintXinty) { for(intI=0;i<6; i++){ for(intj=0;j<7; j + +){ if(pic[i][j]!='.') out[X+i] [y+j]=Pic[i][j]; } } return 0;}intMain () {memset ( out,'.',sizeof( out)); intM,n,h=0;//rows, columns, highscanf"%d%d",&m,&N); inti,j; intR; for(i=1; i<=m;i++){ for(j=1; j<=n;j++) {scanf ("%d",&R); HI[I][J]=R; if(r>h) H=r;//Enter to steal a lazy, record the highest height}//It's like a big space for m*n*h.}//draw selectively when drawing, go to weight when output intx,y,p; for(i=1; i<=m;i++){ for(j=1; j<=n;j++) {p=1; while(hi[i][j]>=p) {x=(2* (I-1)+1)+3* (HQ); Y=(4* (J-1)+1) + (m-i) *2; Write (x, y); P++; } } } intcon=0; Charfo[304]; for(i=1; i<=2*m+1+3*h;i++) {con=0; for(j=1; j<=4*n+2*m+1; j + +) {fo[j-1]= out[I][j]; if( outI [j]!='.') con=1;//to re-judge} fo[j-1]=' /'; if(Con) puts (FO); } return 0;}
NOIP2008 Universal Group 4 Problem Solving-RLQ