HDU 6330 Visual Cube 模拟

/**
Problem L. Visual Cube
链接:http://acm.hdu.edu.cn/showproblem.php?pid=6330
给出a b c 按照一定格式画出长方体.. 
*/

#include<bits/stdc++.h>

using namespace std;

int G[300][300];

int main(){
    int T,l,r,h,n,m,x;
    scanf("%d",&T);
    while(T--){
        scanf("%d%d%d",&l,&r,&h);
        n=2*h+1+2*r;
        m=2*l+1+2*r;
        //cout<<n<<' '<<m<<endl;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++)
                G[i][j]='.';
        }

        for(int i=1;i<=2*r+1;i++){
                x=2*r-i+1;
            for(int j=1;j<=2*l+1;j++)
            if(i&1){
                if(j&1)G[i][x+j]='+';
                else G[i][x+j]='-';
            }
            else{
                if(j&1)G[i][x+j]='/';
            }

        }

        for(int i=n;i>n-2*h;i-=2){
            for(int j=1;j<=2*l+1;j++){
                if(j&1)G[i][j]='+';
                else G[i][j]='-';
            }
            for(int j=1;j<=2*l+1;j++)
                if(j&1)G[i-1][j]='|';
        }
        x=0;int y=2*l+1;
        int z=0;
        for(int i=n-2*h;i<=n;i++){
                x=0;z=0;
            if(i&1){
                for(int j=1;j<=2*r+1;j++){
                    if(j&1)G[i-x][y+z]='+';
                    else G[i-x][y+z]='/';
                    x++;z++;
                }
            }
            else{
                for(int j=1;j<=2*r+1;j++){
                    if(j&1)G[i-x][y+z]='|';
                    else G[i-x][y+z]='.';
                    x++;z++;
                }
            }
        }
        for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)
            printf("%c",G[i][j]);
            printf("\n");
        }
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/hypHuangYanPing/article/details/81812337