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
题目大意:给出长宽高,要求打出这个立体图形。
思路:模拟到爆炸,只能对样例,理清关系又没耐心写,这种题是真的烦,恶心。理清各个关键点的坐标与图像大小再对图形进行填充即可。
标程如下:
#include<cstdio>
const int N=200;
int T,a,b,c,n,m,i,j;char f[N][N];
int main(){
scanf("%d",&T);
while(T--){
scanf("%d%d%d",&a,&b,&c);
n=b*2+c*2+1;
m=a*2+b*2+1;
for(i=1;i<=n;i++)for(j=1;j<=m;j++)f[i][j]='.';
for(i=1;i<=b;i++)for(j=1;j<=a;j++){
f[i*2-1][j*2+1+b*2-i*2]='+';
f[i*2-1][j*2+2+b*2-i*2]='-';
f[i*2-1][j*2+3+b*2-i*2]='+';
f[i*2][j*2+b*2-i*2]='/';
f[i*2][j*2+2+b*2-i*2]='/';
}
for(i=1;i<=c;i++)for(j=1;j<=a;j++){
f[i*2+b*2-1][j*2-1]='+';
f[i*2+b*2-1][j*2]='-';
f[i*2+b*2-1][j*2+1]='+';
f[i*2+b*2][j*2-1]='|';
f[i*2+b*2][j*2+1]='|';
f[i*2+b*2+1][j*2-1]='+';
f[i*2+b*2+1][j*2]='-';
f[i*2+b*2+1][j*2+1]='+';
}
for(i=1;i<=c;i++)for(j=1;j<=b;j++){
f[i*2+b*2-j*2][a*2+j*2+1]='|';
f[i*2+b*2-j*2+1][a*2+j*2+1]='+';
f[i*2+b*2-j*2+2][a*2+j*2]='/';
}
for(i=1;i<=n;i++){
for(j=1;j<=m;j++)putchar(f[i][j]);
puts("");
}
}
}