Visual Cube 杭电多校第三套

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.

思路 : 模拟

未完待续。。。。。。。

#include<stdio.h>
#include<queue>
#include<math.h>
#include<time.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<map>
#include<stack>
#define LL long long
#define mem(a,b) memset(a,b,sizeof(a))
#define lowbit(a) a&(-a)
#define PI acos(-1)
#define shortime(a)  std::ios::sync_with_stdio(a);
using  namespace std;
const LL inf=16777216;
//long long cmp(node a,node b){ if(a.x==b.x) return a.r>b.r;return a.x>b.x;}
int maxn (int a,int b,int c){return max(max(a,b),max(b,c));}
int gcd (int a,int b){return b==0?a:gcd(b,a%b);}
char num[200][200];
void init()
{
    for(int i=1;i<=200;i++)
        for(int j=1;j<=200;j++)
              num[i][j]='.';
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int a,b,c;
        init();
        scanf("%d%d%d",&a,&b,&c);
        int x=(c+b)*2+1,y=(a+b)*2+1;
        for(int i=1;i<=2*b;i++)
        {
            for(int j=1;j<=y+1-i;j++)
            {
                 if(j+i>=2*b+2)
                  {
                      if(i%2==1)
                      {
                          if(j%2==1)
                          {
                              num[i][j]='+';
                          }
                          else num[i][j]='-';
                      }
                      else {
                          if(j%2==0)
                          {
                               num[i][j]='/';
                          }
                      }
                  }
            }
        }
        for(int i=2*b+1;i<=x;i++)
        {
            for(int j=1;j<=y-2*b;j++)
            {
                if(i%2==1)
                {
                    if(j%2==1) num[i][j]='+';
                    else num[i][j]='-';
                }
                else {
                    if((j%2==1)) num[i][j]='|';

                }
            }
        }
        for(int i=2;i<=x;i++)
        {
            for(int j=y-2*b+1;j<=y;j++)
            {
                if(i+j<=x+y-2*b&&i+j>=2+y)
                {
                    if(i%2==1)
                    {
                        if(j%2==1) num[i][j]='+';
                    }
                    else {
                        if(j%2==1) num[i][j]='|';
                        else num[i][j]='/';
                    }
                }
            }
        }
        for(int i=1;i<=x;i++)
        {
            for(int j=1;j<=y;j++)
                printf("%c",num[i][j]);
            putchar('\n');
        }
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_41485193/article/details/81291900
今日推荐