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 aa, width bb and height cc, please write a program to display the cube.
Input
The first line of the input contains an integer T(1≤T≤50)T(1≤T≤50), denoting the number of test cases.
In each test case, there are 33 integers a,b,c(1≤a,b,c≤20)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
..+-+
././|
+-+.+
|.|/.
+-+..
....+-+-+-+-+-+-+
.../././././././|
..+-+-+-+-+-+-+.+
./././././././|/|
+-+-+-+-+-+-+.+.+
|.|.|.|.|.|.|/|/|
+-+-+-+-+-+-+.+.+
|.|.|.|.|.|.|/|/|
+-+-+-+-+-+-+.+.+
|.|.|.|.|.|.|/|/.
+-+-+-+-+-+-+.+..
|.|.|.|.|.|.|/...
+-+-+-+-+-+-+....
题意:
给你一个长方体的长宽高,让你画出这个立体图形
代码:
#include<bits/stdc++.h>
using namespace std;
#define mem(a,b)memset(a,b,sizeof(a))
char p[200][200];
void draw(int x,int y)
{
for(int i=1; i<=x; i++)
{
for(int j=1; j<=y; j++)
printf("%c",p[i][j]);
printf("\n");
}
}
int main()
{
int t,a,b,c;
scanf("%d",&t);
while(t--)
{
mem(p,'.');
scanf("%d%d%d",&a,&b,&c);
for(int i=1; i<=2*b; i++) //上面
if(i&1)
{
for(int j=2*b+1-i+1,k=1; j<=2*a+2*b+1&k<=a+1; j+=2,k++)
p[i][j]='+';
for(int j=2*b+1-i+2,k=1; j<=2*a+2*b+1&&k<=a; j+=2,k++)
p[i][j]='-';
}
else
for(int j=2*b+1-i+1,k=1; j<=2*a+2*b+1&&k<=a+1; j+=2,k++)
p[i][j]='/';
for(int i=2*b+1; i<=2*c+2*b+1; i++) //正面
if(i&1)
{
for(int j=1,k=1; k<=a+1; j+=2,k++)
p[i][j]='+';
for(int j=2,k=1; k<=a; j+=2,k++)
p[i][j]='-';
}
else
for(int j=1,k=1; k<=a+1; j+=2,k++)
p[i][j]='|';
for(int i=2*a+2*b+1,k=1; k<=2*b; i--,k++) //侧面
if(k&1)
for(int j=k,pos=1; j<=k+2*c; j++,pos++)
if(pos&1)
p[j][i]='+';
else
p[j][i]='|';
else
for(int j=k,pos=1; j<=k+2*c+1; j++,pos++)
if(pos&1)
p[j][i]='/';
draw(2*c+2*b+1,2*a+2*b+1);// x=2*c+2*b+1 y=2*a+2*b+1
}
return 0;
}