1 条题解
-
0
C++ :
#include <iostream> using namespace std; const int N = 2007; const char* P[] = { " +---+", " / /|", "+---+ |", "| | +", "| |/ ", "+---+ "}; int a[507][507]; char c[N][N]; inline void Draw(int x, int y) { int i, j; for (j = 0; j < 5; ++j) c[x - 1][y + j] = P[5][j]; for (j = 0; j < 6; ++j) c[x - 2][y + j] = P[4][j]; for (i = 2; i < 4; ++i) for (j = 0; j < 7; ++j) c[x - i - 1][y + j] = P[5 - i][j]; for (j = 1; j < 7; ++j) c[x - 5][y + j] = P[1][j]; for (j = 2; j < 7; ++j) c[x - 6][y + j] = P[0][j]; } int main() { int n, m, h, w, i, j, k = 0, l = 0; fill(c[0], c[0] + N * N, '.'); cin >> n >> m; for (i = 0; i < n; ++i) { for (j = 0; j < m; ++j) { cin >> a[i][j]; k = max(k, 3 * a[i][j] + 3); } k += 2; } k -= 2; l = (m << 2) + (n << 1) + 1; for (i = 0; i < n; ++i) for (j = 0; j < m; ++j) { h = k - ((n - i - 1) << 1); w = ((n - i - 1) << 1) + (j << 2); while (a[i][j]--) { Draw(h, w); h -= 3; } } for (i = 0; i < k; ++i) { for (j = 0; j < l; ++j) cout << c[i][j]; cout << endl; } return 0; }
Pascal :
uses math; var c:array[0..1001,0..1001]of char; g:array[0..101,0..101]of longint; i,j,k,m,n,h,w:longint; procedure draw(x,y:longint); begin c[x,y]:='+';c[x,y+1]:='-';c[x,y+2]:='-';c[x,y+3]:='-';c[x,y+4]:='+'; c[x-1,y]:='|';c[x-1,y+1]:=' '; c[x-1,y+2]:=' ';c[x-1,y+3]:=' ';c[x-1,y+4]:='|';c[x-1,y+5]:='/'; c[x-2,y]:='|';c[x-2,y+1]:=' '; c[x-2,y+2]:=' ';c[x-2,y+3]:=' ';c[x-2,y+4]:='|';c[x-2,y+5]:=' ';c[x-2,y+6]:='+'; c[x-3,y]:='+';c[x-3,y+1]:='-';c[x-3,y+2]:='-';c[x-3,y+3]:='-';c[x-3,y+4]:='+';c[x-3,y+5]:=' ';c[x-3,y+6]:='|'; c[x-4,y+1]:='/';c[x-4,y+2]:=' '; c[x-4,y+3]:=' ';c[x-4,y+4]:=' ';c[x-4,y+5]:='/';c[x-4,y+6]:='|'; c[x-5,y+2]:='+';c[x-5,y+3]:='-';c[x-5,y+4]:='-';c[x-5,y+5]:='-';c[x-5,y+6]:='+'; end; begin readln(n,m); w:=4*m+2*n+1; h:=0; for i:=1 to n do for j:=1 to m do begin read(g[i,j]); h:=max(h,2*(n-i+1)+g[i,j]*3+1); end; for i:=1 to h do for j:=1 to w do c[i,j]:='.'; for i:=1 to n do for j:=1 to m do for k:=1 to g[i,j] do draw(h-2*(n-i)-3*(k-1),2*(n-i)+4*(j-1)+1); for i:=1 to h do begin for j:=1 to w do write(c[i,j]); writeln; end; end.
- 1
信息
- ID
- 263
- 时间
- 1000ms
- 内存
- 50MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者