题解

94 条题解

  • 2
    @ 2017-11-12 17:45:29

    #include <stdio.h>
    int m, n, i, j, k;
    int row, col, max = -1;
    int space[51][51];
    char draw[1000][1000];
    int lie, hang, lie1, hang1;
    void drawing(int row, int col);
    int main() {

    scanf("%d%d", &m, &n);

    for(i = 1; i <= m; i++)
    for(j = 1; j <= n; j++) {
    scanf("%d", &space[i][j]);

    if(max < (1 + (m - i + 1) * 2 + 3 * space[i][j]))
    max = (1 + (m - i + 1) * 2 + 3 * space[i][j]);

    }

    row = 4 * n + 2 * m + 1;
    col = max;
    lie = 1 + (m - 1) * 2;
    hang = col - (m - 1) * 2;

    for(i = 1; i <= col; i++)
    for(j = 1; j <= row; j++)
    draw[i][j] = '.';

    for(i = 1; i <= m; i++) {
    for(j = 1; j <= n; j++) {
    for(k = 1; k <= space[i][j]; k++) {
    drawing(hang, lie);
    hang -= 3;
    }

    lie = 1 + (m - i) * 2;
    hang = col - (m - i) * 2;
    lie += j * 4;
    }

    lie = 1 + (m - 1) * 2;
    hang = col - (m - 1) * 2;
    hang += i * 2;
    lie -= i * 2;
    }

    for(i = 1; i <= col; i++) {
    for(j = 1; j <= row; j++)
    printf("%c", draw[i][j]);

    printf("\n");
    }

    return 0;
    }
    void drawing(int row, int col) {
    int i, j;
    draw[row][col] = '+';
    draw[row - 1][col] = '|';
    draw[row - 2][col] = '|';
    draw[row - 3][col] = '+';
    draw[row][col + 1] = '-';
    draw[row - 1][col + 1] = ' ';
    draw[row - 2][col + 1] = ' ';
    draw[row - 3][col + 1] = '-';
    draw[row - 4][col + 1] = '/';
    draw[row][col + 2] = '-';
    draw[row - 1][col + 2] = ' ';
    draw[row - 2][col + 2] = ' ';
    draw[row - 3][col + 2] = '-';
    draw[row - 4][col + 2] = ' ';
    draw[row - 5][col + 2] = '+';
    draw[row][col + 3] = '-';
    draw[row - 1][col + 3] = ' ';
    draw[row - 2][col + 3] = ' ';
    draw[row - 3][col + 3] = '-';
    draw[row - 4][col + 3] = ' ';
    draw[row - 5][col + 3] = '-';
    draw[row][col + 4] = '+';
    draw[row - 1][col + 4] = '|';
    draw[row - 2][col + 4] = '|';
    draw[row - 3][col + 4] = '+';
    draw[row - 4][col + 4] = ' ';
    draw[row - 5][col + 4] = '-';

    draw[row - 1][col + 5] = '/';
    draw[row - 2][col + 5] = ' ';
    draw[row - 3][col + 5] = ' ';
    draw[row - 4][col + 5] = '/';
    draw[row - 5][col + 5] = '-';
    draw[row - 2][col + 6] = '+';
    draw[row - 3][col + 6] = '|';
    draw[row - 4][col + 6] = '|';
    draw[row - 5][col + 6] = '+';
    }

  • 1
    @ 2021-08-29 17:09:31

    我爱*打表*

    #include<bits/stdc++.h>
    using namespace std;
    
    int i,m,n,j,k,l,o,p,a[1001][1001],ma[1001],maxx,maxy,z[6]={2,1,0,0,0,0},s[6]={6,6,6,6,5,4};
    char c[1001][1001],c1[10][10]={
    "  +---+",
    " /   /|",
    "+---+ |",
    "|   | +",
    "|   |/",
    "+---+",
    };
    
    void fg(int x,int y)
    {
        int i,j;
        for(i=5;i>=0;i--)
            for(j=z[i];j<=s[i];j++)
            {
                c[5-i+x][j+y]=c1[i][j];
                if(5-i+x>maxx)
                    maxx=5-i+x;
                if(j+y>maxy)
                    maxy=j+y;
            }
    }
    
    int main()
    {
        cin>>n>>m;
        for(i=1; i<=n; i++)
            for(j=0; j<m; j++)
                cin>>a[i][j];
        for(o=1; o<=n; o++)
            for(k=0; k<m; k++)
                for(l=0; l<a[o][k]; l++)
                    fg((n-o)*2+1+3*l,(n-o)*2+1+4*k);
        for(i=maxx;i>=1;i--)
        {    
            for(j=1; j<=maxy; j++)
                if(c[i][j]=='\000')
                    cout<<".";
                else
                    cout<<c[i][j];
            cout<<"\n";
        }
    }
    
  • 1
    @ 2019-10-12 19:02:00

    一次AC,开心
    因为数据范围,所以不用考虑宽和高,直接动态赋值(见draw方法)
    (PS:破模拟画尼玛的正方体,写drawCube花了15分钟,整题浪费我一个小时.......

    #include<iostream>
    #define Up(X,Y) for(int i##Y=0;i##Y<(X);++i##Y)
    using namespace std;
    #define MAX 1000
    char canvas[MAX][MAX]={0};
    int minx=MAX,miny=MAX,maxx=0,maxy=0;
    //确定边界范围minXY,maxXY
    void draw(int x,int y,char what){
        canvas[x][y]=what;
        minx=min(x,minx);
        miny=min(y,miny);
        maxx=max(x,maxx);
        maxy=max(y,maxy);
    }
    /*
      +---+
     /   /|
    +---+ |
    |   | +
    |   |/
    +---+
    */
    //以x,y为左下角顶点坐标绘制正方体
    void drawCube(int x,int y){
        //cout<<x<<","<<y<<endl;
        draw(x,y,'+');
        draw(x+1,y,'-');
        draw(x+2,y,'-');
        draw(x+3,y,'-');
        draw(x+4,y,'+');
        
        draw(x,y-1,'|');
        draw(x+1,y-1,' ');
        draw(x+2,y-1,' ');
        draw(x+3,y-1,' ');
        draw(x+4,y-1,'|');
        draw(x+5,y-1,'/');
        
        draw(x,y-2,'|');
        draw(x+1,y-2,' ');
        draw(x+2,y-2,' ');
        draw(x+3,y-2,' ');
        draw(x+4,y-2,'|');
        draw(x+5,y-2,' ');
        draw(x+6,y-2,'+');
        
        draw(x,y-3,'+');
        draw(x+1,y-3,'-');
        draw(x+2,y-3,'-');
        draw(x+3,y-3,'-');
        draw(x+4,y-3,'+');
        draw(x+5,y-3,' ');
        draw(x+6,y-3,'|');
        
        //draw(x,y-4,' ');
        draw(x+1,y-4,'/');
        draw(x+2,y-4,' ');
        draw(x+3,y-4,' ');
        draw(x+4,y-4,' ');
        draw(x+5,y-4,'/');  
        draw(x+6,y-4,'|');  
        
        
    //  draw(x,y-5,' ');
    //  draw(x+1,y-5,' ');
        draw(x+2,y-5,'+');
        draw(x+3,y-5,'-');
        draw(x+4,y-5,'-');
        draw(x+5,y-5,'-');
        draw(x+6,y-5,'+');
    }
    int main(){
        int m,n;
        //画布全部清空
        Up(MAX,1){
            Up(MAX,2){
                canvas[i1][i2]='.';
            }
        }
        cin>>m;
        cin>>n;
        //本行第一块坐标,为防止超过数据边界,从中间开始绘制
        int x0=MAX/2,y0=MAX/2;
        
        //以下按照从后往前,每一行又按从下往上的顺序绘制
        Up(m,1){
            //本行各块高度 
            int levels[n]={0};
            //最大高度 
            int levelmax=0; 
            //确定本行最高要画到第几层
            Up(n,2){
                cin>>levels[i2];
                levelmax=levelmax>levels[i2]?levelmax:levels[i2];
            }
            Up(levelmax,3){
                //i3:当前绘制高度-1 
                Up(n,4){
                    //i4:当前绘制宽度-1 
                    //如果该处有方块,即本块地所需总高度比i3大
                    if(levels[i4]>=i3+1){
                        drawCube(x0+i4*4,y0-i3*3);
                    }
                }
            } 
            
            //移动到下一行的第一块的左下角坐标
            x0-=2;
            y0+=2;
            
        }
        
        //打印,注意(minX,minY)和(maxX,maxY)为所需打印区域
        Up(MAX,1){
            if(i1<miny)continue;
            if(i1>maxy)break;
            Up(MAX,2){
                if(i2<minx||i2>maxx)continue;
                cout<<canvas[i2][i1];
            }
            cout<<endl;
        }
        return 0;
    } 
    
  • 1
    @ 2017-09-23 21:13:58


    #include <iostream>
    #include <cstring>
    using namespace std;
    char map[500][500];
    int h[55][55];
    void cube(int x,int y){
    map[x][ y ]='+';
    map[x][y+1]='-';
    map[x][y+2]='-';
    map[x][y+3]='-';
    map[x][y+4]='+';
    x--;
    map[x][ y ]='|';
    map[x][y+1]=' ';
    map[x][y+2]=' ';
    map[x][y+3]=' ';
    map[x][y+4]='|';
    map[x][y+5]='/';
    x--;
    map[x][ y ]='|';
    map[x][y+1]=' ';
    map[x][y+2]=' ';
    map[x][y+3]=' ';
    map[x][y+4]='|';
    map[x][y+5]=' ';
    map[x][y+6]='+';
    x--;
    map[x][ y ]='+';
    map[x][y+1]='-';
    map[x][y+2]='-';
    map[x][y+3]='-';
    map[x][y+4]='+';
    map[x][y+5]=' ';
    map[x][y+6]='|';
    x--;
    y++;
    map[x][ y ]='/';
    map[x][y+1]=' ';
    map[x][y+2]=' ';
    map[x][y+3]=' ';
    map[x][y+4]='/';
    map[x][y+5]='|';
    x--;
    y++;
    map[x][ y ]='+';
    map[x][y+1]='-';
    map[x][y+2]='-';
    map[x][y+3]='-';
    map[x][y+4]='+';
    }
    int main() {
    int i,j,m,n,mw,mh=0,t,k,x,y;
    memset(map,'.',sizeof(map));
    cin>>m>>n;
    for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
    cin>>h[i][j];
    }
    }
    mw=4*n+1+2*m;
    mh=0;
    for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
    t=3*h[i][j]+3+(m-i)*2;
    if(mh<t)
    mh=t;
    }
    }
    for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
    x=mh-(m-i)*2;
    y=(m-i)*2+(j-1)*4+1;
    for(k=1;k<=h[i][j];k++){
    cube(x-(k-1)*3,y);
    }
    }
    }
    for(i=1;i<=mh;i++){
    for(j=1;j<=mw;j++){
    cout<<map[i][j];
    }
    cout<<endl;
    }
    return 0;
    }

  • 1
    @ 2017-08-05 16:11:40

    我是一行一行画立方体的,不用拉几十行了。
    ```cpp
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>

    char pic[401][301];
    char s0[6] = "+---+", s1[7] = "| |/", s2[8] = "| | +", s3[8] = "+---+ |", s4[7] = "/ /|", s5[6] = "+---+";

    void cube(int i, int j){
    memcpy(&(pic[i][j]), s0, 5 * sizeof(char));
    memcpy(&(pic[i - 1][j]), s1, 6 * sizeof(char));
    memcpy(&(pic[i - 2][j]), s2, 7 * sizeof(char));
    memcpy(&(pic[i - 3][j]), s3, 7 * sizeof(char));
    memcpy(&(pic[i - 4][j + 1]), s4, 6 * sizeof(char));
    memcpy(&(pic[i - 5][j + 2]), s5, 5 * sizeof(char));

    }

    int main(){

    int m, n, h[50][50], maxh = 0; //行数 列数 高度 最大高度
    int hPic = 0, wPic, hTemp; //画布的高度 宽度 临时

    scanf("%d %d", &m, &n);
    wPic = 4 * n + 2 * m + 1;
    for(int i = 0; i < m; i ++){ //i行数
    for(int j = 0; j < n; j ++) { //j列数
    scanf("%d", &(h[i][j]));
    if(h[i][j] > maxh) maxh = h[i][j];
    hTemp = 3 * h[i][j] + 2 * (m - i) + 1;
    if(hTemp > hPic) hPic = hTemp;
    }
    }

    memset(pic, '.', sizeof(pic));
    for(int hgt = 1; hgt <= maxh; hgt ++){ //每层
    for(int i = 0; i < m; i ++){ //每行
    for(int j = 0; j < n; j ++){ //每个
    if(h[i][j] >= hgt) cube(hPic - 1 - 2 * (m - 1 - i) - 3 * (hgt - 1), 4 * j + 2 * (m - 1 - i));
    }
    }
    }

    for(int i = 0; i < hPic; i ++){
    for(int j = 0; j < wPic; j ++){
    printf("%c", pic[i][j]);
    }
    printf("\n");
    }

    return 0;
    }
    ```

  • 1
    @ 2017-03-25 12:34:24

    #include <iostream>
    #include <cstring>
    using namespace std;

    char map[500][500];
    int h[55][55];

    void cube(int x,int y){
    map[x][ y ]='+';
    map[x][y+1]='-';
    map[x][y+2]='-';
    map[x][y+3]='-';
    map[x][y+4]='+';
    x--;
    map[x][ y ]='|';
    map[x][y+1]=' ';
    map[x][y+2]=' ';
    map[x][y+3]=' ';
    map[x][y+4]='|';
    map[x][y+5]='/';
    x--;
    map[x][ y ]='|';
    map[x][y+1]=' ';
    map[x][y+2]=' ';
    map[x][y+3]=' ';
    map[x][y+4]='|';
    map[x][y+5]=' ';
    map[x][y+6]='+';
    x--;
    map[x][ y ]='+';
    map[x][y+1]='-';
    map[x][y+2]='-';
    map[x][y+3]='-';
    map[x][y+4]='+';
    map[x][y+5]=' ';
    map[x][y+6]='|';
    x--;
    y++;
    map[x][ y ]='/';
    map[x][y+1]=' ';
    map[x][y+2]=' ';
    map[x][y+3]=' ';
    map[x][y+4]='/';
    map[x][y+5]='|';
    x--;
    y++;
    map[x][ y ]='+';
    map[x][y+1]='-';
    map[x][y+2]='-';
    map[x][y+3]='-';
    map[x][y+4]='+';
    }

    int main() {
    int i,j,m,n,mw,mh=0,t,k,x,y;
    memset(map,'.',sizeof(map));
    cin>>m>>n;
    for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
    cin>>h[i][j];
    }
    }
    mw=4*n+1+2*m;
    mh=0;
    for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
    t=3*h[i][j]+3+(m-i)*2;
    if(mh<t)
    mh=t;
    }
    }
    for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
    x=mh-(m-i)*2;
    y=(m-i)*2+(j-1)*4+1;
    for(k=1;k<=h[i][j];k++){
    cube(x-(k-1)*3,y);
    }
    }
    }
    for(i=1;i<=mh;i++){
    for(j=1;j<=mw;j++){
    cout<<map[i][j];
    }
    cout<<endl;
    }
    return 0;
    }

  • 1
    @ 2016-11-15 20:41:23

    #include<iostream>
    #include<cstdio>
    using namespace std;
    char map[1000][1000];
    int graph[51][51];
    int n,m;
    int s,t;
    int main(){
    int x,y,r;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++){
    scanf("%d",&graph[i][j]);
    s=max(s,(graph[i][j]+1)*3+2*(n-i));//高
    }
    t=4*m+2*n+1;//宽
    for(int i=1;i<=s;i++)
    for(int j=1;j<=t;j++)
    map[i][j]='.';
    for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++){
    r=s-2*(n-i);
    y=4*j-3+2*(n-i);
    for(int k=0;k<graph[i][j];k++){
    x=r-3*k;
    map[x][y]='+';
    map[x][y+4]='+';
    map[x-3][y]='+';
    map[x-3][y+4]='+';
    map[x-2][y+6]='+';
    map[x-5][y+2]='+';
    map[x-5][y+6]='+';

    map[x][y+1]='-';
    map[x][y+2]='-';
    map[x][y+3]='-';
    map[x-3][y+1]='-';
    map[x-3][y+2]='-';
    map[x-3][y+3]='-';
    map[x-5][y+3]='-';
    map[x-5][y+4]='-';
    map[x-5][y+5]='-';

    map[x-4][y+1]='/';
    map[x-1][y+5]='/';
    map[x-4][y+5]='/';

    map[x-1][y]='|';
    map[x-2][y]='|';
    map[x-1][y+4]='|';
    map[x-2][y+4]='|';
    map[x-3][y+6]='|';
    map[x-4][y+6]='|';

    map[x-2][y+5]=' ';
    map[x-3][y+5]=' ';
    map[x-4][y+2]=' ';
    map[x-4][y+3]=' ';
    map[x-4][y+4]=' ';
    map[x-1][y+1]=' ';
    map[x-1][y+2]=' ';
    map[x-1][y+3]=' ';
    map[x-2][y+1]=' ';
    map[x-2][y+2]=' ';
    map[x-2][y+3]=' ';

    }
    }
    for(int i=1;i<=s;i++){
    for(int j=1;j<=t;j++){
    cout<<map[i][j];
    }
    cout<<endl;
    }
    return 0;
    }

  • 1
    @ 2016-11-10 16:16:05

    #2016.11.15 update:看到一堆0ms过的再看看我45ms感到不满于是稍加优化

    评测结果
    编译成功

    Free Pascal Compiler version 3.0.0 [2015/11/16] for i386
    Copyright (c) 1993-2015 by Florian Klaempfl and others
    Target OS: Win32 for i386
    Compiling foo.pas
    Linking foo.exe
    44 lines compiled, 0.0 sec, 28304 bytes code, 1268 bytes data
    测试数据 #0: Accepted, time = 15 ms, mem = 908 KiB, score = 10
    测试数据 #1: Accepted, time = 15 ms, mem = 908 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 912 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 908 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 912 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 912 KiB, score = 10
    测试数据 #6: Accepted, time = 15 ms, mem = 912 KiB, score = 10
    测试数据 #7: Accepted, time = 15 ms, mem = 908 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 908 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 908 KiB, score = 10
    Accepted, time = 60 ms, mem = 912 KiB, score = 100
    代码
    ```pascal
    {$inline on}
    const dian='+';heng='-';shu='|';xie='/';
    var m,n,i,j,k,maxy:longint;
    d:array[1..300,1..300] of char;
    map:array[1..50,1..50] of longint;

    function max(a,b:longint):longint;inline;
    begin if a>b then exit(a);exit(b);end;

    procedure render(x,y:longint);inline;
    var i,j:longint;
    begin
    for i:=1 to 3 do d[x+i,y]:=heng;
    for i:=1 to 3 do d[x+i,y+3]:=heng;
    for i:=3 to 5 do d[x+i,y+5]:=heng;
    for i:=1 to 2 do d[x,y+i]:=shu;
    for i:=1 to 2 do d[x+4,y+i]:=shu;
    for i:=3 to 4 do d[x+6,y+i]:=shu;
    d[x,y]:=dian;d[x,y+3]:=dian;d[x+4,y]:=dian;d[x+4,y+3]:=dian;d[x+2,y+5]:=dian;
    d[x+6,y+5]:=dian;d[x+6,y+2]:=dian;
    d[x+1,y+4]:=xie;d[x+5,y+4]:=xie;d[x+5,y+1]:=xie;
    for i:=1 to 3 do for j:=1 to 2 do d[x+i,y+j]:=' ';
    for i:=2 to 4 do d[x+i,y+4]:=' ';
    for i:=2 to 3 do d[x+5,y+i]:=' ';
    end;

    begin
    readln(m,n);
    maxy:=0;
    for j:=m downto 1 do
    for i:=1 to n do begin
    read(map[j,i]);
    maxy:=max(maxy,j<<1+3*map[j,i]+1);
    end;
    for i:=1 to n<<2+1+m<<1 do
    for j:=1 to maxy do d[i,j]:='.';
    for i:=m downto 1 do
    for j:=1 to n do
    for k:=1 to map[i,j] do
    render(i<<1+j<<2-5,i<<1+3*k-4);
    for i:=maxy downto 1 do begin
    for j:=1 to n<<2+1+m<<1 do write(d[j,i]);
    writeln;
    end;
    end.
    ```

  • 1
    @ 2015-10-07 14:47:39

    program exercise(input,output);
    var n,m,l,r,i,j,k,p,q,x,y:longint;
    map:array[1..50,1..50]of longint;
    s:array[1..500]of ansistring;
    begin
    readln(n,m);
    l:=0;
    r:=n*2+m*4+1;
    for i:=1 to n do
    begin
    for j:=1 to m do
    begin
    read(map[i,j]);
    if map[i,j]*3+(n-i)*2+3>l then
    l:=map[i,j]*3+(n-i)*2+3;
    end;
    readln;
    end;
    for i:=1 to l do
    while length(s[i])<r do
    s[i]:=s[i]+'.';
    for i:=1 to n do
    for j:=1 to m do
    for k:=1 to map[i,j] do
    begin
    x:=l-k*3-(n-i)*2+3;
    y:=(n-i)*2+j*4-3;
    for p:=x-5 to x-2 do
    for q:=y+2 to y+6 do
    if (p=x-5)or(p=x-2) then
    if (q=y+2)or(q=y+6) then
    s[p][q]:='+'
    else
    s[p][q]:='-'
    else
    if (q=y+2)or(q=y+6) then
    s[p][q]:='|'
    else
    s[p][q]:=' ';
    for p:=x-3 to x do
    for q:=y to y+4 do
    if (p=x-3)or(p=x) then
    if (q=y)or(q=y+4) then
    s[p][q]:='+'
    else
    s[p][q]:='-'
    else
    if (q=y)or(q=y+4) then
    s[p][q]:='|'
    else
    s[p][q]:=' ';
    s[x-2][y+5]:=' ';
    s[x-4][y+2]:=' ';
    s[x-1][y+5]:='/';
    s[x-4][y+5]:='/';
    s[x-4][y+1]:='/';
    end;
    for i:=1 to l do
    writeln(s[i]);
    end.

  • 0
    @ 2018-08-17 12:25:59

    因为需要让前面的立方体遮挡住后面的立方体,可以先绘制后面的立方体,再绘制前面的(每次更新画布上的元素,擦去原先的),这样就能够做到了。代码如下:

    #include <bits/stdc++.h>
    using namespace std;
    char out[205][105];
    int pointx[]={0,4,0,4,6,6,2};
    int pointy[]={0,0,-3,-3,-2,-5,-5};
    void draw(int x,int y)
    {
    for(int i=0;i<7;i++)
    {
    out[x+pointx[i]][y+pointy[i]]='+';
    }/*绘制顶点*/
    for(int i=1;i<=3;i++)
    {
    out[x+i][y]='-';
    out[x+i][y-3]='-';
    out[x+2+i][y-5]='-';
    }/*绘制长*/
    out[x+5][y-1]='/';out[x+5][y-4]='/';out[x+1][y-4]='/';
    /*绘制宽*/
    for(int i=1;i<=2;i++)
    {
    out[x][y-i]='|';
    out[x+4][y-i]='|';
    out[x+6][y-2-i]='|';
    }/*绘制高*/
    for(int i=1;i<=3;i++)
    {
    for(int t=-1;t>=-2;t--)
    {
    out[x+i][y+t]=' ';
    }
    }/*绘制正面*/
    out[x+5][y-2]=' ';out[x+5][y-3]=' ';/*绘制侧面*/
    for(int i=1;i<=3;i++)
    {
    out[x+1+i][y-4]=' ';
    }/*绘制顶面*/
    }
    int main()
    {
    int m,n;int num[50][50];int begx;int begy;int x;int y;int allx;int ally=0;
    scanf("%d%d",&n,&m);allx=1+2*n+4*m;
    for(int i=0;i<n;i++)
    {
    for(int t=0;t<m;t++)
    {
    scanf("%d",&num[t][i]);
    if(2*(n-i)+num[t][i]*3+1>ally)
    {
    ally=2*(n-i)+num[t][i]*3+1;
    }
    }
    }
    for(int i=0;i<allx;i++)
    {
    for(int t=0;t<ally;t++)
    {
    out[i][t]='.';
    }
    }
    begx=2*n;begy=ally-2*n-1;
    for(int i=0;i<n;i++)
    {
    begx-=2;begy+=2;
    for(int t=0;t<m;t++)
    {
    x=begx+4*t;y=begy;
    for(int j=0;j<num[t][i];j++)
    {
    draw(x,y-3*j);
    }
    }
    }
    for(int i=0;i<ally;i++)
    {
    for(int t=0;t<allx;t++)
    {
    printf("%c",out[t][i]);
    }
    printf("\n");
    }
    }

  • 0
    @ 2017-08-28 19:41:35

    这道题
    真的恶心

    #include <iostream>
    #include <cstring>
    using namespace std;
    const char block[6][7]={{'.','.','+','-','-','-','+'},
                                    {'.','/',' ',' ',' ','/','|'},
                                    {'+','-','-','-','+',' ','|'},
                                    {'|',' ',' ',' ','|',' ','+'},
                                    {'|',' ',' ',' ','|','/','.'},
                                    {'+','-','-','-','+','.','.'}
    };
    long map[51][51];
    char out[1001][1001];
    void paintblock(long x,long y)
    {
        long i,j;
        for (i=0;i<=5;i++)
            for (j=0;j<=6;j++)
                if (block[i][j]!='.')
                    out[x+i][y+j]=block[i][j];
        
    
    }
    int main()
    {
        long i,j,k,n,m,K,L,sx,sy,MaxU;
        cin>>n>>m;
        for (i=1;i<=n;i++)
            for (j=1;j<=m;j++)
                cin>>map[i][j];
        L=4*m+1+2*n;
        MaxU=0;
        for (i=1;i<=n;i++)
            for (j=1;j<=m;j++)
                MaxU=max(MaxU,3*(map[i][j]+1)-2*i);
        K=MaxU+2*n;
        memset(out,'.',sizeof(out));
        for (i=1;i<=n;i++)
            for (j=1;j<=m;j++){
                sx=MaxU+2*(i-1); //Standard Line
                sy=2*(n-i)+4*j-3;
                for (k=1;k<=map[i][j];k++)
                    paintblock(sx-3*k,sy);
            }
        for (i=1;i<=K;i++){
            for (j=1;j<=L;j++)
                cout<<out[i][j];
            cout<<endl;
        }
        return 0;
    }
    
  • 0
    @ 2017-07-04 08:16:36

    这个模拟有点恶心
    做了一晚上
    不辜负我1AC

  • 0
    @ 2017-05-31 19:04:33

    Accepted

    /in/foo.cc: In function 'int draw(int, int)':
    /in/foo.cc:29:1: warning: no return statement in function returning non-void [-Wreturn-type]
    }
    ^

    状态 耗时 内存占用

    #1 Accepted 3ms 384.0KiB
    #2 Accepted 2ms 256.0KiB
    #3 Accepted 2ms 256.0KiB
    #4 Accepted 4ms 256.0KiB
    #5 Accepted 3ms 360.0KiB
    #6 Accepted 3ms 256.0KiB
    #7 Accepted 3ms 256.0KiB
    #8 Accepted 3ms 260.0KiB
    #9 Accepted 2ms 352.0KiB
    #10 Accepted 3ms 384.0KiB
    代码

    
    #include <iostream>
    #include <algorithm>
    using namespace std;
    int m,n,map[55][55],x,y;
    char pic[400][500];
    //..+---+
    //./   /|
    //+---+ |
    //|   | +
    //|   |/.
    //+---+..
    int cx(int a,int b)
    {
        int dx=2*(m-a)+1+4*(b-1);
        return dx;
    }
    int cy(int a,int c)
    {
        int dy=y-(2*(m-a)+3*(c-1));
        return dy;
    }
    int draw(int dx,int dy)
    {
        pic[dx+2][dy-4]=pic[dx+3][dy-4]=pic[dx+4][dy-4]=pic[dx+1][dy-2]=pic[dx+2][dy-2]=pic[dx+3][dy-2]=pic[dx+1][dy-1]=pic[dx+2][dy-1]=pic[dx+3][dy-1]=pic[dx+5][dy-2]=pic[dx+5][dy-3]=' ';
        pic[dx+5][dy-1]=pic[dx+1][dy-4]=pic[dx+5][dy-4]='/';
        pic[dx+3][dy-5]=pic[dx+4][dy-5]=pic[dx+5][dy-5]=pic[dx+1][dy]=pic[dx+2][dy]=pic[dx+3][dy]=pic[dx+1][dy-3]=pic[dx+2][dy-3]=pic[dx+3][dy-3]='-';
        pic[dx][dy-1]=pic[dx][dy-2]=pic[dx+4][dy-1]=pic[dx+4][dy-2]=pic[dx+6][dy-3]=pic[dx+6][dy-4]='|';
        pic[dx][dy]=pic[dx+4][dy]=pic[dx+6][dy-2]=pic[dx][dy-3]=pic[dx+4][dy-3]=pic[dx+2][dy-5]=pic[dx+6][dy-5]='+';
    }
    int main()
    {
        cin>>m>>n;
        for(int i=1;i<=m;i++)
            for(int j=1;j<=n;j++)
            {
                cin>>map[i][j];
                y=max(y,3+2*m-2*i+3*map[i][j]);
            }
        x=1+4*n+2*m;
        for(int i=1;i<=y;i++)
            for(int j=1;j<=x;j++)
                pic[j][i]='.';
        for(int i=1;i<=m;i++)
            for(int j=1;j<=n;j++)
                for(int k=1;k<=map[i][j];k++)
                    draw(cx(i,j),cy(i,k));
        for(int i=1;i<=y;i++)
        {
            for(int j=1;j<=x;j++)
                cout<<pic[j][i];
            cout<<"\n";
        }
        return 0;
    }
    
  • 0
    @ 2016-11-10 15:52:41

    第一次把代码写这么整齐...
    pascal
    program P1497;
    var
    pic:array[0..250,0..250] of char;
    a:array[1..50,1..50] of integer;
    i,j,k,m,n,x,y,maxi:integer;
    procedure print(x,y:integer);
    begin
    pic[x,y]:=chr(43);
    pic[x,y+1]:=chr(45);
    pic[x,y+2]:=chr(45);
    pic[x,y+3]:=chr(45);
    pic[x,y+4]:=chr(43);
    pic[x-1,y-1]:=chr(47);
    pic[x-1,y]:=' ';
    pic[x-1,y+1]:=' ';
    pic[x-1,y+2]:=' ';
    pic[x-1,y+3]:=chr(47);
    pic[x-1,y+4]:=chr(124);
    pic[x-2,y-2]:=chr(43);
    pic[x-2,y-1]:=chr(45);
    pic[x-2,y]:=chr(45);
    pic[x-2,y+1]:=chr(45);
    pic[x-2,y+2]:=chr(43);
    pic[x-2,y+3]:=' ';
    pic[x-2,y+4]:=chr(124);
    pic[x-3,y-2]:=chr(124);
    pic[x-3,y-1]:=' ';
    pic[x-3,y]:=' ';
    pic[x-3,y+1]:=' ';
    pic[x-3,y+2]:=chr(124);
    pic[x-3,y+3]:=' ';
    pic[x-3,y+4]:=chr(43);
    pic[x-4,y-2]:=chr(124);
    pic[x-4,y-1]:=' ';
    pic[x-4,y]:=' ';
    pic[x-4,y+1]:=' ';
    pic[x-4,y+2]:=chr(124);
    pic[x-4,y+3]:=chr(47);
    pic[x-5,y-2]:=chr(43);
    pic[x-5,y-1]:=chr(45);
    pic[x-5,y]:=chr(45);
    pic[x-5,y+1]:=chr(45);
    pic[x-5,y+2]:=chr(43);
    end;
    begin
    readln(m,n);
    for i:=1 to m do
    begin
    for j:=1 to n do read(a[i,j]);
    readln;
    end;
    fillchar(pic,sizeof(pic),chr(46));
    pic[0,0]:=chr(43);
    for i:=1 to m do
    for j:=1 to n do
    for k:=1 to a[i,j] do
    begin
    x:=(m-i+1)*2+3*k;
    y:=(j-1)*4+2*(m-i+1);
    print(x,y);
    end;
    for i:=0 to 250 do
    for j:=1 to 250 do if pic[i,j]<>chr(46) then maxi:=i;
    for i:=maxi downto 0 do
    begin
    for j:=0 to (4*n+2*m) do write(pic[i,j]);
    writeln;
    end;
    end.

  • 0
    @ 2016-08-24 14:56:09

    so water!
    ```c++
    评测结果
    编译成功

    测试数据 #0: Accepted, time = 0 ms, mem = 724 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 724 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 728 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 724 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 724 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 724 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 724 KiB, score = 10
    测试数据 #7: Accepted, time = 0 ms, mem = 724 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 728 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 724 KiB, score = 10
    Accepted, time = 0 ms, mem = 728 KiB, score = 100
    代码
    #include <algorithm>
    #include <iostream>
    using namespace std;
    //ifstream cin("drawing.in",ios :: in);
    //ofstream cout("drawing.out",ios :: out);
    char map[401][401];
    int cnt[51][51];
    inline void draw(int x,int y) {map[x+2][y+0] = '+';map[x+3][y+0] = '-';map[x+4][y+0] = '-';map[x+5][y+0] = '-';map[x+6][y+0] = '+';map[x+1][y+1] = '/';map[x+2][y+1] = ' ';map[x+3][y+1] = ' ';map[x+4][y+1] = ' ';map[x+5][y+1] = '/';map[x+6][y+1] = '|';map[x+0][y+2] = '+';map[x+1][y+2] = '-';map[x+2][y+2] = '-';map[x+3][y+2] = '-';map[x+4][y+2] = '+';map[x+5][y+2] = ' ';map[x+6][y+2] = '|';map[x+0][y+3] = '|';map[x+1][y+3] = ' ';map[x+2][y+3] = ' ';map[x+3][y+3] = ' ';map[x+4][y+3] = '|';map[x+5][y+3] = ' ';map[x+6][y+3] = '+';map[x+0][y+4] = '|';map[x+1][y+4] = ' ';map[x+2][y+4] = ' ';map[x+3][y+4] = ' ';map[x+4][y+4] = '|';map[x+5][y+4] = '/';map[x+0][y+5] = '+';map[x+1][y+5] = '-';map[x+2][y+5] = '-';map[x+3][y+5] = '-';map[x+4][y+5] = '+';}
    int main() {
    ios :: sync_with_stdio(false);
    int n,m;
    cin >> m >> n;
    int y = 0;
    int x = n*4+m*2+1;
    for (int i = 1;i <= 400;i++)
    for (int j = 1;j <= 400;j++) map[i][j] = '.';
    for (int i = 1;i <= m;i++)
    for (int j = 1;j <= n;j++) {
    cin >> cnt[i][j];
    y = max(y,(m-i+1)*2+cnt[i][j]*3+1);
    }
    for (int i = 1;i <= m;i++)
    for (int j = 1;j <= n;j++)
    for (int k = 1;k <= cnt[i][j];k++)
    draw((j-1)*4+(m-i)*2+1,y-(3*k+(m-i+1)*2));
    for (int i = 1;i <= y;i++) {
    for (int j = 1;j <= x;j++)
    cout << map[j][i];
    cout << '\n';
    }
    return 0;
    }
    ```

  • 0
    @ 2016-04-18 22:26:05

    比较懒。。。先打表打出画一个方块的代码

    assign(f,'t.txt');
    rewrite(f);
    for i:=1 to 6 do begin
      for j:=1 to 7 do begin
        read(c);
        if c='.' then continue;
        write(f,'dg[x+',j-1,',y+',i-1,']:=',chr(39),c,chr(39),'; ');
      end;
      writeln(f);
      readln;
    end;
    close(f); 
    

    然后求解

    uses math;
    var m,n,i,j,k:integer;
      mx,my:integer;
      g:array[0..50,0..50] of integer;
      dg:array[0..400,0..400] of char;
    
    //以左上角(x,y)画一个方块
    procedure draw(x,y:integer);
    var i,j:integer;
    begin
      dg[x+2,y+0]:='+'; dg[x+3,y+0]:='-'; dg[x+4,y+0]:='-'; dg[x+5,y+0]:='-'; dg[x+6,y+0]:='+';
      dg[x+1,y+1]:='/'; dg[x+2,y+1]:=' '; dg[x+3,y+1]:=' '; dg[x+4,y+1]:=' '; dg[x+5,y+1]:='/'; dg[x+6,y+1]:='|';
      dg[x+0,y+2]:='+'; dg[x+1,y+2]:='-'; dg[x+2,y+2]:='-'; dg[x+3,y+2]:='-'; dg[x+4,y+2]:='+'; dg[x+5,y+2]:=' '; dg[x+6,y+2]:='|';
      dg[x+0,y+3]:='|'; dg[x+1,y+3]:=' '; dg[x+2,y+3]:=' '; dg[x+3,y+3]:=' '; dg[x+4,y+3]:='|'; dg[x+5,y+3]:=' '; dg[x+6,y+3]:='+';
      dg[x+0,y+4]:='|'; dg[x+1,y+4]:=' '; dg[x+2,y+4]:=' '; dg[x+3,y+4]:=' '; dg[x+4,y+4]:='|'; dg[x+5,y+4]:='/';
      dg[x+0,y+5]:='+'; dg[x+1,y+5]:='-'; dg[x+2,y+5]:='-'; dg[x+3,y+5]:='-'; dg[x+4,y+5]:='+';
    end;
    
    begin
      read(m,n);
      fillchar(dg,sizeof(dg),'.');
      my:=0; //画布高
      mx:=n*4+m*2+1; //画布宽
      for i:=1 to m do
        for j:=1 to n do begin
          read(g[i,j]);
          my:=max(my,(m-i+1)*2+g[i,j]*3+1);
        end;
      //画方块
      for i:=1 to m do
        for j:=1 to n do
          for k:=1 to g[i,j] do
            draw((j-1)*4+(m-i)*2+1,my-(3*k+(m-i+1)*2));
      //输出
      for i:=1 to my do begin
        for j:=1 to mx do write(dg[j,i]);
        writeln;
      end;
    end.
    
  • 0
    @ 2015-11-29 08:36:59

    好难

  • 0
    @ 2014-10-22 18:20:48

    ###block code
    #include <iostream>

    using namespace std;

    int m,n;
    int cnt[64][64]={0};

    char pic[1024][1024];
    int height=0,width=0;

    void setsize(){
    for (int i=m-1;i>=0;i--)
    for (int j=0;j<n;j++)
    height=max(height,cnt[i][j]*3+3+(m-i-1)*2);
    width=n*4+1+m*2;
    }

    void loaddata(){
    cin>>m>>n;
    for (int i=0;i<m;i++)
    for (int j=0;j<n;j++)
    cin>>cnt[i][j];
    }

    void clear(){
    for (int i=0;i<height;i++)
    for (int j=0;j<width;j++)
    pic[j][i]='.';
    }

    void print(){
    for (int i=0;i<height;i++){
    for (int j=0;j<width;j++)
    cout<<pic[j][i];
    cout<<endl;
    }
    }

    void render(int x,int y,int z){
    int sx,sy;
    //cout<<__func__<<" "<<x<<" "<<y<<" "<<z<<endl;
    sx=x*4+y*2; sy=height-(3*z+y*2+1);
    pic[sx][sy]=pic[sx+4][sy]=pic[sx][sy-3]=pic[sx+4][sy-3]=
    pic[sx+2][sy-5]=pic[sx+6][sy-5]=pic[sx+6][sy-2]='+';
    pic[sx+1][sy]=pic[sx+2][sy]=pic[sx+3][sy]=
    pic[sx+1][sy-3]=pic[sx+2][sy-3]=pic[sx+3][sy-3]=
    pic[sx+3][sy-5]=pic[sx+4][sy-5]=pic[sx+5][sy-5]='-';
    pic[sx+1][sy-4]=pic[sx+5][sy-4]=pic[sx+5][sy-1]='/';
    pic[sx][sy-1]=pic[sx][sy-2]=pic[sx+4][sy-1]=pic[sx+4][sy-2]=
    pic[sx+6][sy-3]=pic[sx+6][sy-4]='|';
    pic[sx+1][sy-1]=pic[sx+2][sy-1]=pic[sx+3][sy-1]=
    pic[sx+1][sy-2]=pic[sx+2][sy-2]=pic[sx+3][sy-2]=
    pic[sx+2][sy-4]=pic[sx+3][sy-4]=pic[sx+4][sy-4]=
    pic[sx+5][sy-2]=pic[sx+5][sy-3]=' ';
    //print();
    }

    int main(){
    loaddata();
    setsize();
    clear();
    for (int i=0;i<m;i++)
    for (int j=0;j<n;j++)
    for (int k=0;k<cnt[i][j];k++)
    render(j,m-i-1,k);
    print();
    return 0;
    }

  • 0
    @ 2014-07-06 20:30:31

    program drawing;
    var m,n,i,j,top,h:longint;
    pic:array[0..310,0..310]of char;
    mun:array[0..51,0..51]of longint;
    procedure tu(a,b,c:longint);
    var i:longint;
    begin
    for i:=1 to c do
    begin
    pic[a,b]:='+'; pic[a,b+1]:='-'; pic[a,b+2]:='-'; pic[a,b+3]:='-'; pic[a,b+4]:='+';
    pic[a+1,b]:='|';pic[a+1,b+1]:=' ';pic[a+1,b+2]:=' ';pic[a+1,b+3]:=' ';pic[a+1,b+4]:='|';pic[a+1,b+5]:='/';
    pic[a+2,b]:='|';pic[a+2,b+1]:=' ';pic[a+2,b+2]:=' ';pic[a+2,b+3]:=' ';pic[a+2,b+4]:='|';pic[a+2,b+5]:=' ';pic[a+2,b+6]:='+';
    pic[a+3,b]:='+';pic[a+3,b+1]:='-';pic[a+3,b+2]:='-';pic[a+3,b+3]:='-';pic[a+3,b+4]:='+';pic[a+3,b+5]:=' ';pic[a+3,b+6]:='|';
    pic[a+4,b+1]:='/';pic[a+4,b+2]:=' ';pic[a+4,b+3]:=' ';pic[a+4,b+4]:=' ';pic[a+4,b+5]:='/';pic[a+4,b+6]:='|';
    pic[a+5,b+2]:='+';pic[a+5,b+3]:='-';pic[a+5,b+4]:='-';pic[a+5,b+5]:='-';pic[a+5,b+6]:='+';
    a:=a+3;
    end;
    end;

    begin
    assign(input,'drawing.in');
    reset(input);
    assign(output,'drawing.out');
    rewrite(output);
    read(m,n);
    h:=0;top:=0;
    for i:=m downto 1 do
    for j:=1 to n do
    begin
    read(mun[i,j]);
    if h<mun[i,j]then h:=mun[i,j];
    end;
    fillchar(pic,sizeof(pic),'.');
    for i:=m downto 1 do
    for j:=1 to n do tu((i-1)*2+1,(j-1)*4+1+(i-1)*2 ,mun[i,j]);
    for i:=(h*3+1)+(m*2+1) downto 1 do
    begin
    for j:=1 to m*2+n*4+1 do if pic[i,j]<>'.'then begin top:=i; break;end;
    if top<>0 then break;
    end;
    for i:=top downto 1 do
    begin
    for j:=1 to m*2+n*4+1 do write(pic[i,j]);
    writeln;
    end;
    close(input);
    close(output);
    end.

    • @ 2015-11-29 08:23:48

      nanananananananannaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnncccccnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyuuuuuuuuuuuuuuuuuuuuuuuuuuuuuurrrrrrrrrrrrrrrrriiiiiiiiiiiiieeoooooooooooeeeeeeeeeeeeepppppppppppppeeeeeeeeeeeeeeeooooooooooorrrrrrrttttttttttttyyyyyyyyyyyyyyyyyyyoooooooooooooooouuuuuuuuuuuuuuooooooooooooouuuuuuuuuuuuuuuuuuuooooooooooooooouuuuuuuuuuuuuuuuuuiiiiiiiiiiiiiiiyyyyyyyyyyyyppppppppppppptttttttttrrrrrrrrrrrrrrrrrreeeeeeeeeeeeewwwwwwwwwwwwwwwwwwwwqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrreeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeetttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaahhhhhhhhhhhhhhhhhhhhhhhhhhaaaaaaaaaaaaaaaaaaaaaaaaaahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhaaaaaaaaaaaaaaaaaaaaaaaaaaaaaahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhaaaaaaaaaaaaaaaaaaaaa

  • 0
    @ 2013-11-01 21:12:13

    #include <stdio.h>
    #include <string.h>
    #define N 60
    #define M 1000
    char map[M][M];
    int cal[N][N];
    int height,width;
    int max(int a,int b){return a>b?a:b;}
    void painting(int x,int y,int k){
    int i,j;
    for(i=0;i<k;i++){
    map[x+i*3][y]='+'; map[x+i*3+1][y]='|';map[x+i*3+2][y]='|';
    for(j=1;j<=3;j++){
    map[x+i*3][y+j]='-';
    map[x+i*3+1][y+j]=' ';
    map[x+i*3+2][y+j]=' ';
    }
    map[x+i*3][y+4]='+'; map[x+i*3+1][y+4]='|';map[x+i*3+2][y+4]='|';
    map[x+i*3+1][y+4+1]='/'; map[x+i*3+1+1][y+4+1]=' ';map[x+i*3+2+1][y+4+1]=' ';
    map[x+i*3+2][y+4+2]='+'; map[x+i*3+1+2][y+4+2]='|';map[x+i*3+2+2][y+4+2]='|';
    }
    map[x+k*3][y]='+';
    for(j=1;j<=3;j++) map[x+k*3][y+j]='-';
    map[x+k*3][y+4]='+';

    map[x+k*3+1][y+1]='/';
    for(j=1;j<=3;j++) map[x+k*3+1][y+j+1]=' ';
    map[x+k*3+1][y+4+1]='/';

    map[x+k*3+2][y+2]='+';
    for(j=1;j<=3;j++) map[x+k*3+2][y+j+2]='-';
    map[x+k*3+2][y+4+2]='+';

    return ;
    }
    void output(){
    int i,j;
    for(i=height;i>=0;i--,puts(""))
    for(j=0;j<width;j++){
    printf("%c",map[i][j]);
    }
    return ;
    }
    int main(){
    int i,j;
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF){
    height=0;
    width=1+m*4+2*n;
    for(i=n;i>=1;i--){
    for(j=1;j<=m;j++){
    scanf("%d",&cal[i][j]);
    height=max(height,2*i+cal[i][j]*3);
    }
    }
    memset(map,'.',sizeof(map));
    for(i=n;i>=1;i--){
    for(j=1;j<=m;j++){
    painting((i-1)*2,(j-1)*4+(i-1)*2,cal[i][j]);
    }
    }
    output();
    }
    return 0;
    }

信息

ID
1497
难度
2
分类
字符串 | 模拟 点击显示
标签
递交数
1932
已通过
1120
通过率
58%
被复制
18
上传者