Problem L. Visual Cube
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 2127 Accepted Submission(s): 984
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<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
char G[1000][1000];
int main(){
// freopen("1.txt", "r", stdin);
int T;
scanf("%d", &T);
while(T--){
memset(G,0,sizeof(G));
int chang,kuan, gao;
scanf("%d%d%d", &chang, &kuan, &gao);
char ch1,ch2;
for(int i=1;i<=gao*2+kuan*2+1; i++){
if(i%2) ch1='+',ch2='-';
else ch1='|',ch2='.';
for(int j=1;j<=chang*2 + kuan * 2+1; j++){
if(j % 2) G[i][j]=ch1;
else G[i][j]=ch2;
}
}
ch1='.',ch2='/';
for(int i=1; i<= kuan; i++){
for(int j=1;j<=chang*2+1+i*2-1; j++){
//printf("%d %d\n",2*(gao+i), j);
if(j % 2) G[2*(gao+i)][j]=ch1;
else G[2*(gao+i)][j]=ch2;
}
}
for(int j=1; j<= kuan; j++){
for(int i=1;i<=gao*2+1+j*2-1; i++){
if(i % 2) G[i][2*(chang+j)]=ch1;
else G[i][2*(chang+j)]=ch2;
}
}
for(int i=1;i <= kuan*2; i++){
for(int j=i;j<=2*(chang+kuan)+1;j++){
G[i][2*chang+1+j]='.';
}
}
for(int j=1;j <= kuan*2; j++){
for(int i=j;i<=2*(gao+kuan)+1;i++){
G[2*gao+1+i][j]='.';
}
}
for(int i=2*(gao+kuan)+1;i>=1;i--){
for(int j=1;j<=2*(chang+kuan)+1;j++){
putchar(G[i][j]);
}
putchar('\n');
}
}
}