[HDU](6330) ---- Problem L. Visual Cube

2018 Multi-University Training Contest 3

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

..+-+
././|
+-+.+
|.|/.
+-+..
....+-+-+-+-+-+-+
.../././././././|
..+-+-+-+-+-+-+.+
./././././././|/|
+-+-+-+-+-+-+.+.+
|.|.|.|.|.|.|/|/|
+-+-+-+-+-+-+.+.+
|.|.|.|.|.|.|/|/|
+-+-+-+-+-+-+.+.+
|.|.|.|.|.|.|/|/.
+-+-+-+-+-+-+.+..
|.|.|.|.|.|.|/...
+-+-+-+-+-+-+....

 

模拟题:个人水平有限,写的超级复杂,还是太蒻了

超霸说找规律so easy~ QAQ

AC代码:简单看看就好,代码权值几乎为0

#include<bits/stdc++.h>
using namespace std;
int main()
{
    #ifdef LOCAL_FILE
    freopen("in.txt","r",stdin);
    #endif // LOCAL_FILE
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t;
    int c,k,g;
    cin>>t;
    while(t--)
    {
        cin>>c>>k>>g;
        for(int i=1;i<=2*(g+k)+1;i++)
        {
            for(int j=1;j<=2*(c+k)+1;j++)
            {
                if(i>=1 && i<=(2*k)+1-1)//上
                {
                    if(i%2 == 1)
                    {
                        if(i <= 2*g+1)
                        {
                            if(j>=1 && j<=2*(c+k)+1-(2*c+i)+2*c+1+(i-1))
                            {
                                if((2*(c+k)+1)-j<(2*c+i))
                                {
                                    if((j-(2*(c+k)+1-(2*c+i)))>=1 && (j-(2*(c+k)+1-(2*c+i)))<=2*c+1 && j%2 == 0)
                                    {
                                        cout<<"-";
                                    }
                                    else if(j%2 == 1)
                                        cout<<"+";
                                    else
                                        cout<<".";
                                }
                                else
                                    cout<<".";
                            }
                        }
                        else
                        {
                            if(j>=1 && j<=2*(c+k)+1-(2*c+i)+2*c+1+(2*g+1-1))
                            {
                                if((2*(c+k)+1)-j<(2*c+i))
                                {
                                    if((j-(2*(c+k)+1-(2*c+i)))>=1 && (j-(2*(c+k)+1-(2*c+i)))<=2*c+1 && j%2 == 0)
                                    {
                                        cout<<"-";
                                    }
                                    else if(j%2 == 1)
                                        cout<<"+";
                                    else
                                        cout<<".";
                                }
                                else
                                    cout<<".";
                            }
                            else
                                cout<<".";
                        }
                    }
                    else if(i%2 == 0)
                    {
                        if(i <= 2*g+1)
                        {
                            if(j>=1 && j<=2*(c+k)+1-(2*c+i)+2*c+1+(i-1))
                            {
                                if((2*(c+k)+1)-j<(2*c+i))
                                {
                                    if((j-(2*(c+k)+1-(2*c+i)))>=1 && (j-(2*(c+k)+1-(2*c+i)))<=2*c+1 && j%2 == 1)
                                    {
                                        cout<<".";
                                    }
                                    else if(j%2 == 0 && j!=2*(c+k)+1)
                                        cout<<"/";
                                    else
                                        cout<<"|";
                                }
                                else
                                    cout<<".";
                            }
                        }
                        else
                        {
                            if(j>=1 && j<=2*(c+k)+1-(2*c+i)+2*c+1+(2*g+1-1))
                            {
                                if((2*(c+k)+1)-j<(2*c+i))
                                {
                                    if((j-(2*(c+k)+1-(2*c+i)))>=1 && (j-(2*(c+k)+1-(2*c+i)))<=2*c+1 && j%2 == 1)
                                    {
                                        cout<<".";
                                    }
                                    else if(j%2 == 0 && j!=2*(c+k)+1)
                                        cout<<"/";
                                    else
                                        cout<<"|";
                                }
                                else
                                    cout<<".";
                            }
                            else
                                cout<<".";
                        }
                    }
                }
                else if(i>=(2*k+1) && i<=(2*k+1)+(2*(g+k)+1-2*(2*k)-1))//中
                {
                    if(i%2 == 1)
                    {
                        if(j>=1 && j<=(2*c+1) && j%2 == 0)
                            cout<<"-";
                        else if(j%2 == 1)
                            cout<<"+";
                        else
                            cout<<".";
                    }
                    else if(i%2 == 0)
                    {
                        if(j>=1 && j<=(2*c+1) && j%2 == 0)
                            cout<<".";
                        else if(j%2 == 1)
                            cout<<"|";
                        else
                            cout<<"/";
                    }
                }
                else if(i>=(2*k+1)+(2*(g+k)+1-2*(2*k)) && i<=2*(g+k)+1)//下
                {
                    if(i%2 == 0)
                    {
                        if(j>=1 && j<=( (2*(c+k)+1)-((i-((2*k+1)+(2*(g+k)+1-2*(2*k)-1)))) ) )
                        {
                            if(j>=1 && j<=(2*c+1) && j%2 == 0)
                                cout<<".";
                            else if(j%2 == 1)
                                cout<<"|";
                            else
                                cout<<"/";
                        }
                        else
                            cout<<".";
                    }
                    else if(i%2 == 1)
                    {
                        if(j>=1 && j<=( (2*(c+k)+1)-((i-((2*k+1)+(2*(g+k)+1-2*(2*k)-1)))) ) )
                        {
                            if(j>=1 && j<=(2*c+1) && j%2 == 0)
                                cout<<"-";
                            else if(j%2 == 1)
                                cout<<"+";
                            else
                                cout<<".";
                        }
                        else
                            cout<<".";
                    }
                }
            }
            cout<<endl;
        }
    }
    return 0;
}

 

阅读更多
版权声明:本文为博主原创文章,转载请预先通知博主(〃'▽'〃)。 https://blog.csdn.net/m0_37624640/article/details/81291853
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭