HDU - 2018 Multi-University Training Contest 3 - 1012: Visual Cube

简介: HDU - 2018 Multi-University Training Contest 3 - 1012: Visual Cube

Problem L. Visual Cube

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)

Total Submission(s): 1473    Accepted Submission(s): 694


Problem Description


Little Q likes solving math problems very much. Unluckily, however, he does not have good spatial ability. Everytime he meets a 3D geometry problem, he will struggle to draw a picture.

Now he meets a 3D geometry problem again. This time, he doesn't want to struggle any more. As a result, he turns to you for help.

Given a cube with length a, width b and height c, please write a program to display the cube.


Input


The first line of the input contains an integer T(1≤T≤50), denoting the number of test cases.

In each test case, there are 3 integers a,b,c(1≤a,b,c≤20), denoting the size of the cube.



Output


For each test case, print several lines to display the cube. See the sample output for details.


Sample Input

2

1 1 1

6 2 4



Sample Output


image.png


解题思路:立体图分为:俯视图 + 正视图 + 右视图,此题先刷 俯视图 + 正视图,最后刷 右视图;一开始先记录每个视图有哪些规律图案,比如:“+-+-+-+”、“/././././”,然后再创建一个全是“点”的二维数组,把它描上去即可。

AC 代码

#include<bits/stdc++.h>
#include<cmath>
#define mem(a,b) memset(a,b,sizeof a);
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
int main()
{
    int T; scanf("%d",&T);
    int a,b,c;
    while(T-- && ~scanf("%d%d%d",&a,&b,&c))
    {
        string zf,xd,sd,dx,sz;
        for(int i=0;i<a;i++)
        {
            zf.append("+-");
            xd.append("/.");
            sd.append("|.");
        }
        zf.append("+"); xd.append("/"); sd.append("|");
        for(int i=0;i<c;i++)
        {
            sz.append("|+");
            dx.append("./");
        }
//        cout<<"+-:"<<zf<<endl;
//        cout<<"/.:"<<xd<<endl;
//        cout<<"|.:"<<sd<<endl;
//        cout<<"./:"<<dx<<endl;
//        cout<<"|+:"<<sz<<endl;
        int rlen=2*c+1+2*b,clen=2*a+1+2*b;
        int con=2*b;
        char g[rlen+5][clen+5]; mem(g,'.');
        for(int i=0;i<rlen;i++,con--)
        {
            for(int j=0;j<clen;j++)
            {
                if(con>0)
                {
                    if(j+con<clen && i%2==0 && j<zf.length())
                        g[i][j+con]=zf[j];
                    else if(j+con<clen && i%2==1 && j<xd.length())
                        g[i][j+con]=xd[j];
                }
                else
                {
                    if(i%2==0 && j<zf.length())
                        g[i][j]=zf[j];
                    else if(i%2==1 && j<sd.length())
                        g[i][j]=sd[j];
                }
            }
        }
        // 正视图和俯视图刷完,可以快速排错
//        for(int i=0;i<rlen;i++)
//        {
//            for(int j=0;j<clen;j++)
//            {
//                printf("%c",g[i][j]);
//            }
//            puts("");
//        }
//        puts("-----------------");
        // 右视图刷完
        con=2*b;
        int h=2*c,t=0;
        for(int j=clen-1;j>=0 && con--;j--,t++)
        {
            for(int i=1+t;i<=h+t;i++)
            {
                if(j%2==0 && i-1-t<sz.length())
                    g[i][j]=sz[i-1-t];
                else if(j%2==1 && i-1-t<dx.length())
                    g[i][j]=dx[i-1-t];
            }
        }
        for(int i=0;i<rlen;i++)
        {
            for(int j=0;j<clen;j++)
            {
                printf("%c",g[i][j]);
            }
            puts("");
        }
    }
    return 0;
}
目录
相关文章
|
Java
HDU - 2018 Multi-University Training Contest 2 - 1010: Swaps and Inversions
HDU - 2018 Multi-University Training Contest 2 - 1010: Swaps and Inversions
113 0
|
Java
HDU - 2018 Multi-University Training Contest 2 - 1004: Game
HDU - 2018 Multi-University Training Contest 2 - 1004: Game
104 0
|
Java
HDU - 2018 Multi-University Training Contest 1 - 1001: Maximum Multiple
HDU - 2018 Multi-University Training Contest 1 - 1001: Maximum Multiple
99 0
|
Java
2017 Multi-University Training Contest - Team 9 1003&&HDU 6163 CSGO【计算几何】
CSGO Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 127    Accepted Submission(s): 20 Pro...
1416 0
|
Java
2017 Multi-University Training Contest - Team 9 1005&&HDU 6165 FFF at Valentine【强联通缩点+拓扑排序】
FFF at Valentine Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1060    Accepted Submission(...
1209 0
2017 Multi-University Training Contest - Team 9 1004&&HDU 6164 Dying Light【数学+模拟】
Dying Light Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 513    Accepted Submission(s): ...
1183 0
|
Java
2017 Multi-University Training Contest - Team 9 1002&&HDU 6162 Ch’s gift【树链部分+线段树】
Ch’s gift Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1354    Accepted Submission(s): 496 Problem Description Mr.
1300 0
2017 Multi-University Training Contest - Team 1 1003&&HDU 6035 Colorful Tree【树形dp】
Colorful Tree Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1539    Accepted Submission(s...
1335 0
|
Java 人工智能 BI
2017 Multi-University Training Contest - Team 1 1006&&HDU 6038 Function【DFS+数论】
Function Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 652    Accepted Submission(s): 267...
1193 0