航电多校第三场—— Visual Cube(模拟)

 

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

..+-+
././|
+-+.+
|.|/.
+-+..
....+-+-+-+-+-+-+
.../././././././|
..+-+-+-+-+-+-+.+
./././././././|/|
+-+-+-+-+-+-+.+.+
|.|.|.|.|.|.|/|/|
+-+-+-+-+-+-+.+.+
|.|.|.|.|.|.|/|/|
+-+-+-+-+-+-+.+.+
|.|.|.|.|.|.|/|/.
+-+-+-+-+-+-+.+..
|.|.|.|.|.|.|/...
+-+-+-+-+-+-+....

Source

2018 Multi-University Training Contest 3

#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define re(ss,dd,ww) for(int ww=ss;ww<dd;++ww)
#define er(ss,dd,ww) for(int ww=dd;ww>=ss;--ww)
#define wl(ss) while(ss)
int main(){
	int t;
	scanf("%d",&t);
	wl(t--){
		int l,s,d;
		scanf("%d %d %d",&l,&s,&d);
		int w=1;
		re(0,s,i){
			re(0,2,j) printf(".");
		}
		printf("+");
		re(0,l,i) printf("-+");
		printf("\n");
		if(s<=d){
		er(s-1,0,i){
			//
			for(int j=0;j<i*2+1;j++)
				printf(".");
			printf("/");
			for(int j=0;j<l;j++)
				printf("./");
			for(int j=s-1;j>i;j--){
				printf("|/");
			}
			printf("|\n");
			//
			for(int j=0;j<i*2;j++)
				printf(".");
			printf("+");
			for(int j=0;j<l;j++)
				printf("-+");
			for(int j=s-1;j>=i;j--){
				printf(".+");
			}
			printf("\n");
		}
		for(int i=0;i<d-s;i++){
			printf("|");
			for(int j=0;j<l;j++)
				printf(".|");
			for(int j=0;j<s;j++)
				printf("/|");
			printf("\n");
			printf("+");
			for(int j=0;j<l;j++)
				printf("-+");
			for(int j=0;j<s;j++)
				printf(".+");
			printf("\n");
		}
		for(int i=d-s;i<d;i++){
			printf("|");
			for(int j=0;j<l;j++)
				printf(".|");
			for(int j=i;j<d-1;j++)
				printf("/|");
			printf("/");
			for(int j=0;j<w;j++)
				printf(".");
			printf("\n");
			printf("+");
			for(int j=0;j<l;j++)
				printf("-+");
			for(int j=i;j<d-1;j++)
				printf(".+");
			for(int j=0;j<=w;j++)
				printf(".");
			printf("\n");
			w+=2;
		}
		}
		else{
			for(int i=s-1;i>=0;i--){
			//
			for(int j=0;j<i*2+1;j++)
				printf(".");
			printf("/");
			for(int j=0;j<l;j++)
				printf("./");
			if(i>=s-d){
			for(int j=s-1;j>i;j--){
				printf("|/");
			}
			printf("|\n");
			}
			else{
				//printf("%d",w);
				for(int j=d;j>=1;j--)
					printf("|/");
				//printf("/");
				for(int j=0;j<w;j++)
					printf(".");
				printf("\n");
			}
			//
			for(int j=0;j<i*2;j++)
				printf(".");
			printf("+");
			for(int j=0;j<l;j++)
				printf("-+");
			if(i>=s-d){
			for(int j=s-1;j>=i;j--){
				printf(".+");
			}
			printf("\n");
			}
			else{
				for(int j=d;j>=1;j--)
					printf(".+");
				for(int j=0;j<=w;j++)
					printf(".");
				printf("\n");
				w+=2;
			}
		}
		for(int i=0;i<d;i++){
			printf("|");
			for(int j=0;j<l;j++)
				printf(".|");
			for(int j=i;j<d-1;j++)
				printf("/|");
			printf("/");
			for(int j=0;j<w;j++)
				printf(".");
			printf("\n");
			printf("+");
			for(int j=0;j<l;j++)
				printf("-+");
			for(int j=i;j<d-1;j++)
				printf(".+");
			for(int j=0;j<=w;j++)
				printf(".");
			printf("\n");
			w+=2;
		}
		}
	}
}

猜你喜欢

转载自blog.csdn.net/doublekillyeye/article/details/81295481