当前位置: 代码迷 >> 综合 >> Problem L. Visual Cube
  详细解决方案

Problem L. Visual Cube

热度:71   发布时间:2023-11-18 14:55:27.0

题目直通:http://acm.hdu.edu.cn/showproblem.php?pid=6330

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>
char s[1000][1000];
void init(){for(int i=1;i<=500;i++){for(int j=1;j<=500;j++){s[i][j]='.';}}
}
int main()
{int t;scanf("%d",&t);while(t--){init();int a,b,c;scanf("%d%d%d",&a,&b,&c);for(int i=1;i<=b+b+c+c+1;i++){if(i<=b+b){if(i%2==1){int j;for(j=b+b-i+2;j<=a+a+1+b+b-i;j++){if(j%2==1)s[i][j]='+';else s[i][j]='-';}for(;j<=a+a+1+b+b;j++){if(j%2==1)s[i][j]='+';}}else{int j;for(j=b+b-i+2;j<=a+a+1+b+b-i;j++){if(j%2==0){s[i][j]='/';}}for(;j<=a+a+1+b+b;j++){if(j%2==0){s[i][j]='/';}else s[i][j]='|';}}}else if(i<=c+c+1){if(i%2==1){int j;for(j=1;j<=a+a;j++){if(j%2==1)s[i][j]='+';else s[i][j]='-';}for(;j<=a+a+1+b+b;j++){if(j%2==1)s[i][j]='+';}}else{int j;for(j=1;j<=a+a;j++){if(j%2==1)s[i][j]='|';}for(;j<=a+a+1+b+b;j++){if(j%2==1)s[i][j]='|';else s[i][j]='/';}}}else{if(i%2==1){int j;for(j=1;j<=a+a;j++){if(j%2==0){s[i][j]='-';}else s[i][j]='+';}for(;j<=a+a+2-i+b+b+c+c;j++){if(j%2==1){s[i][j]='+';}}}else{int j;for(j=1;j<=a+a;j++){if(j%2==1){s[i][j]='|';}}for(;j<=a+a+2-i+b+b+c+c;j++){if(j%2==1){s[i][j]='|';}else{s[i][j]='/';}}}}}int k=1;for(int i=(c+c+1+b+b);i>=(c+c+1);i--){for(int j=a+a+1+k;j<=a+a+1+b+b;j++){s[i][j]='.';}k++;}for(int i=1;i<=c+c+1+b+b;i++){for(int j=1;j<=b+b+a+a+1;j++){printf("%c",s[i][j]);}printf("\n");}}return 0;
}

 

  相关解决方案