HDU多校联合第四场问题 问题 L: Problem L. Visual Cube(构图)

问题 L: Problem L. Visual Cube

时间限制: 1 Sec  内存限制: 512 MB
提交: 42  解决: 31
[提交] [状态] [讨论版] [命题人:admin]

题目描述

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. 
/upload/file/20180730/20180730154407_29748.pdf
 

样例输入

2
1 1 1
6 2 4

样例输出

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

小结:自己的思路为啥总是这么麻烦别人代码好简单 哎哎哎哎哎哎

/* autor pinkpan*/ 
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define IO ios::sync_with_stdio(false),cin.tie(0)
#define FIN freopen("D://code//in.txt", "r", stdin)
#define ppr(i,x,n) for(int i = x;i <= n;i++)
#define rpp(i,n,x) for(int i = n;i >= x;i--)
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 7;
const double pi = acos(-1);
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
 
inline int read() {//读入挂
    int ret = 0, c, f = 1;
    for(c = getchar(); !(isdigit(c) || c == '-'); c = getchar());
    if(c == '-') f = -1, c = getchar();
    for(; isdigit(c); c = getchar()) ret = ret * 10 + c - '0';
    if(f < 0) ret = -ret;
    return ret;
}
int a,b,c;
char mmp[105][105];
int main()
{
	int t,n;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d%d",&a,&b,&c);
		int n = 2*(b+c),m = 2*(a+b);
		ppr(i,0,n)
		{
			ppr(j,0,m)
			{
				if(i % 2 == 0)
				{
					if(i < 2*b)
					{
						if(j >= 2*b-i)
						{
							if(j % 2 == 0)
							{
								mmp[i][j] = '+';
							}
							else
							{
								if(j <= m-i)
								{
									mmp[i][j] = '-';
								}
								else
								{
									mmp[i][j] = '.';
								}
							}
						}
						else
						{
							mmp[i][j] = '.';
						}
					}
					else if(i >= 2*b && i <= n-2*b)
					{
						if(j % 2 == 0)
						mmp[i][j] = '+';
						else
						{
							if(j <= 2*a)
								{
									mmp[i][j] = '-';
								}
								else
								{
									mmp[i][j] = '.';
								}
						}
					}
					else
					{
						if(j > m-(i-n+2*b))
						mmp[i][j] = '.';
						else 
						{
							if(j % 2 == 0)
							{
								mmp[i][j] = '+';
							}
							else
							{
								if(j > a*2)
								mmp[i][j] = '.';
								else
								mmp[i][j] = '-';
							}
						}
					}
				}
				else
				{
					if(i < 2*b)
					{
						if(j >= 2*b-i)
						{
							if(j % 2 == 1)
							{
								mmp[i][j] = '/';
							}
							else
							{
								if(j <= m-i)
								{
									mmp[i][j] = '.';
								}
								else
								{
									mmp[i][j] = '|';
								}
							}
						}
						else
						{
							mmp[i][j] = '.';
						}
					}
					else if(i >= 2*b && i <= n-2*b)
					{
						if(j % 2 == 0)
						mmp[i][j] = '|';
						else
						{
							if(j <= 2*a)
								{
									mmp[i][j] = '.';
								}
								else
								{
									mmp[i][j] = '/';
								}
						}
					}
					else
					{
						if(j > m-(i-n+2*b))
						mmp[i][j] = '.';
						else 
						{
							if(j % 2 == 0)
							{
								mmp[i][j] = '|';
							}
							else
							{
								if(j > a*2)
								mmp[i][j] = '/';
								else
								mmp[i][j] = '.';
							}
						}
					}
				}
			}
		}
		if(n < 4*b)
		{	
			int cnt = 1;
			ppr(i,2*c+1,2*b-1)
			{
				int j = m;
				for(int k = cnt;k > 0;k--)
				{
					mmp[i][j] = '.';
					j--;
				}
				cnt++;
			}
		} 
		ppr(i,0,n)
			{
				ppr(j,0,m)
				{
					printf("%c",mmp[i][j]);
				}
				printf("\n");
			}
		
	}
	return 0;
} 

猜你喜欢

转载自blog.csdn.net/Pandapan1997/article/details/81328631