题目链接: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. Input The first line of the input contains an integer T(1≤T≤50) , denoting the number of test cases. 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 |
AC代码:
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
int a,x,y,z,i,j,k;
scanf("%d",&a);
while(a--)
{
scanf("%d %d %d",&x,&y,&z);
for (i = 2*y; i >0; i--)
{
for (j = i; j > 0; j--)
printf(".");
if (i%2 == 0)
{
for (j = 0; j < x; j++)
printf("+-");
for (k = 0; k <= 2*y-i; k++)
{
if (k <=2*z)
{
if ((k+i)%2 != 0)
printf(".");
else printf("+");
}
else printf(".");
}
}
else
{
for (j = 0; j < x; j++)
printf("/.");
for (k = 0; k <= 2*y-i; k++)
{
if (k <= 2*z)
{
if ((k+i)%2 != 0)
printf("/");
else printf("|");
}
else printf(".");
}
}
printf("\n");
}
for (i = max(2*(z-y)+1,1); i > 0; i--)
{
if (i%2 != 0)
{
for (j = 0; j < x; j++)
printf("+-");
for (k = 0; k <= 2*y; k++)
{
if (k <= 2*z)
{
if (k%2 != 0)
printf(".");
else printf("+");
}
else printf(".");
}
}
else
{
for (j = 0; j < x; j++)
printf("|.");
for (k = 0; k <= 2*y; k++)
{
if (k <= 2*z)
{
if (k%2 != 0)
printf("/");
else printf("|");
}
else printf(".");
}
}
printf("\n");
}
for (i = min(2*y,2*z); i >0; i--)
{
if (i%2 != 0)
{
for (j = 0; j < x; j++)
printf("+-");
for (k = 0; k < i; k++)
{
if (k <= 2*z)
{
if (k%2 != 0)
printf(".");
else printf("+");
}
else printf(".");
}
}
else
{
for (j = 0; j < x; j++)
printf("|.");
for (k = 0; k < i; k++)
{
if (k <= 2*z)
{
if (k%2 != 0)
printf("/");
else printf("|");
}
else printf(".");
}
}
for (j = 2*y-i+1; j > 0; j--)
printf(".");
printf("\n");
}
}
return 0;
}