Problem L Visual Cube

Problem L Visual Cube

题目:

Problem L. Visual Cube

http://acm.hdu.edu.cn/showproblem.php?pid=6330

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 55    Accepted Submission(s): 45

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

Recommend

chendu

思路:

  模拟题,先用‘’.‘’填充所有的,然后先填顶面,再填正面,最后填侧面。题目不难,但是有些复杂,所以要细心,注意分类讨论,注意边界的情况。

代码:

#include<cstdio>
using namespace std;
char s[100][100];
int maxn = 100;
void put(int row,int col)
{
    for(int i=1; i<=row; i++)
    {
        for(int j=1; j<=col; j++)
            printf("%c",s[i][j]);
        puts("");
    }
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);

        for(int i=1; i<100; i++)
            for(int j=1; j<100; j++)
                s[i][j]=‘.‘;
        ///顶面
        int indexj = b*2+1;
        for(int i=1; i<=b*2; i++)
        {
            if(i%2)
            {
                for(int j=indexj; j<=indexj+2*a; j++)
                {
                    if(j%2)s[i][j]=‘+‘;
                    else s[i][j]=‘-‘;
                }
            }
            else
            {
                for(int j=indexj; j<=indexj+2*a; j++)
                {
                    if(j%2==0)s[i][j]=‘/‘;
                    else s[i][j]=‘.‘;
                }
            }
            indexj--;

        }
        ///正面
        for(int i=b*2+1; i<=b*2+1+c*2; i++)
        {
            if((i-b*2)%2)
            {
                for(int j=1; j<=a*2+1; j++)
                {
                    if(j%2)s[i][j]=‘+‘;
                    else s[i][j]=‘-‘;
                }
            }
            else
            {
                for(int j=1; j<=a*2+1; j++)
                {
                    if(j%2)s[i][j]=‘|‘;
                    else s[i][j]=‘.‘;
                }
            }
        }
        ///侧面
        int indexi=2*b+1;
        for(int j=a*2+1; j<=a*2+b*2+1; j++)
        {

            if((j-a*2)%2)
            {
                for(int i=indexi; i<=indexi+c*2; i++)
                {
                    if((i-indexi)%2==0)
                        s[i][j]=‘+‘;
                    else s[i][j]=‘|‘;
                }
            }
            else
            {
                for(int i=indexi; i<=indexi+c*2; i++)
                {
                    if((i-indexi)%2==0)
                        s[i][j]=‘/‘;
                    else s[i][j]=‘.‘;
                }

            }
            indexi--;

        }

        int hh = b*2+1+c*2;
        int ll = a*2+b*2+1;
        put(hh,ll);
    }

    return 0;
}

原文地址:https://www.cnblogs.com/longl/p/9392308.html

时间: 2024-11-25 20:52:53

Problem L Visual Cube的相关文章

(2018 Multi-University Training Contest 3)Problem L. Visual Cube

//题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6330//题目大意:按照一定格式画出一个 a×b×c 的长方体.  //解题思路:计算画布大小以及各个关键位置的坐标.按照格式将画布填充正确.逐步覆盖就对了,csy说这是全场最简单的题!虽然我们是第三个做的~ 1 #include <bits/stdc++.h> 2 using namespace std; 3 char s[100][100]; 4 int main() 5 { 6 int T

XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem L. Canonical duel

题目:Problem L. Canonical duelInput file: standard inputOutput file: standard outputTime limit: 2 secondsMemory limit: 256 megabytesIn the game ?Canonical duel? board N × M is used. Some of the cells of the board contain turrets. Aturret is the unit wi

Problem L: 搜索基础之马走日

Problem L: 搜索基础之马走日 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 134  Solved: 91[Submit][Status][Web Board] Description 马在中国象棋以日字形规则移动. 请编写一段程序,给定n*m大小的棋盘,以及马的初始位置(x,y),要求不能重复经过棋盘上的同一个点,计算马可以有多少途径遍历棋盘上的所有点. Input 第一行为整数T(T < 10),表示测试数据组数.每一组测试数据包含一

华农oj Problem L: CreatorX背英语【STL】

Problem L: CreatorX背英语 Time Limit: 1 Sec Memory Limit: 64 MB Submit: 53 Solved: 36 [Submit][Status][Web Board] Description CreatorX最近在忙着背英语, Hzk is a young and beautiful and cute boy 但是正常背诵的效果他觉得不好,于是他又想了一个点子,倒着背. Boy cute and beautiful and young a i

2018 Multi-University Training Contest 4 Problem L. Graph Theory Homework 【YY】

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6343 Problem L. Graph Theory Homework Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1536    Accepted Submission(s): 830 Problem Description Ther

UESTC_Ferris Wheel String 2015 UESTC Training for Search Algorithm &amp; String&lt;Problem L&gt;

L - Ferris Wheel String Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 43000/43000KB (Java/Others) Submit Status Have you ever been to London? Our Master Qiu will tell you how amazing in London and how funny a Ferris Wheel String is. One day

UESTC_Rain in ACStar 2015 UESTC Training for Data Structures&lt;Problem L&gt;

L - Rain in ACStar Time Limit: 9000/3000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submit Status Maybe you have heard of Super Cow AC who is the great general of ACM Empire. However, do you know where he is from? This is one of th

UESTC_菲波拉契数制升级版 2015 UESTC Training for Dynamic Programming&lt;Problem L&gt;

L - 菲波拉契数制升级版 Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submit Status 我们定义如下数列为菲波拉契数列: F(1)=1 F(2)=2 F(i)=F(i−1)+F(i−2)(i>=3) 给定任意一个数,我们可以把它表示成若干互不相同的菲波拉契数之和.比如13有三种表示法 13=13 13=5+8 13=2+3+8 现在给你一个数n,请输出把它表示成

UESTC_方老师和农场 2015 UESTC Training for Graph Theory&lt;Problem L&gt;

L - 方老师和农场 Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submit Status 方老师重新开了一家农场,农场一共有N个节点和M条双向边,但是有一个很大的问题就是有比如一个农场A到达农场B只有一条路径,问至少添加多少条边使得任意两个农场之间的路径多于一条. Input 多组数据,EOF结束. 第1行:N和M. 第2到第M+1行:每一行2个数Ui和Vi,表示Ui到