• 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(1T50), denoting the number of test cases.
    In each test case, there are 3 integers a,b,c(1a,b,c20), 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
    ..+-+ ././| +-+.+ |.|/. +-+.. ....+-+-+-+-+-+-+ .../././././././| ..+-+-+-+-+-+-+.+ ./././././././|/| +-+-+-+-+-+-+.+.+ |.|.|.|.|.|.|/|/| +-+-+-+-+-+-+.+.+ |.|.|.|.|.|.|/|/| +-+-+-+-+-+-+.+.+ |.|.|.|.|.|.|/|/. +-+-+-+-+-+-+.+.. |.|.|.|.|.|.|/... +-+-+-+-+-+-+....
     
     
    #include <bits/stdc++.h>
    
    using namespace std;
    
    int main()
    {
        int T;
        cin>>T;
        while(T--)
        {
            int a,b,c;
            cin>>a>>b>>c;
            char Map[200][200];
            for(int i=0;i<2*b;i++)
            {
                for(int j=2*b-i;j>=0;j--)
                {
                    Map[i][j] = '.';
                }
            }
            for(int i=0;i<2*b;i++)
            {
                int j;
                if(i%2==0)
                {
                    int k;
                    for(j=2*b-i,k=0;k<a;k++,j+=2)
                    {
                        Map[i][j] = '+';
                        Map[i][j+1] = '-';
                    }
                    Map[i][j] = '+';
                    j++;
                    while(j<=(2*(a+b)))
                    {
                        if(j%2==0)
                        {
                            Map[i][j] = '+';
                        }
                        else
                        {
                            Map[i][j] = '.';
                        }
                        j++;
                    }
                }
                else
                {
                    int k;
                    for(j=2*b-i,k=0;k<a;k++,j+=2)
                    {
                        Map[i][j] = '/';
                        Map[i][j+1] = '.';
                    }
                    Map[i][j] ='/';
                    while(j<=(2*(a+b)))
                    {
                        if(j%2==0)
                        {
                            Map[i][j] = '|';
                        }
                        else
                        {
                            Map[i][j] = '/';
                        }
                        j++;
                    }
                }
            }
    
            for(int i=2*b;i<=2*b+2*c;i++)
            {
                if(i%2==0)
                {   int j;
                    for(j=0;j<=2*a;j+=2)
                    {
                        Map[i][j] = '+';
                        Map[i][j+1] = '-';
                    }
                    j--;
                    while(j<=2*a+2*b)
                    {
                        if(j%2==0)
                        {
                            Map[i][j] = '+';
                        }
                        else
                        {
                            Map[i][j] ='.';
                        }
                        j++;
                    }
                }
                else
                {
                  //  cout<<"*"<<endl;
                    int j;
                    for(j=0;j<=2*a;j+=2)
                    {
                        Map[i][j] = '|';
                        Map[i][j+1] = '.';
                    }
                    j--;
                    while(j<=2*a+2*b)
                    {
                        if(j%2==0)
                        {
                            Map[i][j] = '|';
                        }
                        else
                        {
                            Map[i][j] ='/';
                        }
                        j++;
                    }
                }
            }
    
            for(int i=2*c+1,k=0;i<=2*b+2*c;i++,k++)
            {
                int t = k;
                for(int j=2*a+2*b;t>=0;j--,t--)
                {
                    Map[i][j] = '.';
                }
            }
    
            for(int i=0;i<=2*b+2*c;i++)
            {
                for(int j=0;j<=2*a+2*b;j++)
                {
                    cout<<Map[i][j];
                }
                cout<<endl;
            }
        }
    }
  • 相关阅读:
    【GoLang】GoLang map 非线程安全 & 并发度写优化
    【IDEA】IDEA 如何设置编辑器字体大小
    【GoLang】GoLang fmt 占位符详解
    转头条:阿里p7架构师:三年经验应该具备什么样的技能?
    RPC与RMI的区别
    为什么使用消息队列,为什么使用RabbitMQ、springAMQP
    cookie的安全性问题
    solr与mysql数据同步的方案
    springcloud与dubbo对比:
    mybatis与分布式事务的面试
  • 原文地址:https://www.cnblogs.com/hao-tian/p/9390560.html
Copyright © 2020-2023  润新知