4083 Candy Dreamer

本篇介绍了一个有趣的编程挑战——CandyDreamer。任务是根据特定尺寸和材料输入,使用代码绘制出一个圆柱形糖果的图形。输入包括材料字符、直径和长度,输出则是由指定材料构成的糖果图形。

Candy Dreamer

Time Limit: 1000MS Memory Limit: 65536KB

 

Problem Description

    That's so annoying that ldq's nephew, ldh is always sticking to him! In order to gain a little peace, ldq determined to fulfill one of ldh's dream. For ldh, nothing is better than a tasty candy as he is a candy lover. But just ask for some candy? No, that's more or less simple! After a while, ldh came to ldq with the last edition of his little dream:

    Give me a candy with the required size and ingredient(even the candy wrapper is made of it). The candy is a cylinder so you will know its diameter and length.

    What a realistic but difficult-to-achieve dream, ldq thought. Somehow he has known that you have the ability to turn codes into real things(or say the ability to draw a candy), so help him, please!

Input

There are several cases of input, ending up with EOF.

For each case there is one line of input with three parameters:

  • igr -- a non-blank character,represents the ingredient of the candy
  • dia -- an integer,represents the diameter of the candy
  • len -- an integer,represents the length of the candy
  • (dia = 2k+1, k = 1,2,...; 1 < dia <= 25, 1 <= len <= 25) they are separated by spaces

Output

Output the figure of the candy, refering to the example output.

Be careful that there's a space between every two adjacent ingredients.

Every two adjacent cases are also seperated by a blank line.

Example Input

# 5 7
2 5 1

Example Output

#       # # # # # # #       #
# #   # # # # # # # # #   # #
# # # # # # # # # # # # # # #
# #   # # # # # # # # #   # #
#       # # # # # # #       #

2       2       2
2 2   2 2 2   2 2
2 2 2 2 2 2 2 2 2
2 2   2 2 2   2 2
2       2       2
#include<bits/stdc++.h>
using namespace std;
char mmp[30][100];

int main()
{
    char s;
    int n,m;
    while(cin >> s >> n >>m)
    {
        memset(mmp,s,sizeof(mmp));
        for(int i =0;i<n/2;i++)
        {
            for(int j = i+1;j < n-1-i;j++)
            {
                mmp[i][j] = ' ';
            }
            for(int j = i+1 +m+n-2;j < n-1-i +m+n-2;j++)
            {
                mmp[i][j] = ' ';
            }
        }
        for(int i=n-1; i>n/2;i--)
        {
            for(int j = 0;j < 2*n+m-2;j++)
            {
                mmp[i][j] = mmp[n-1-i][j];
            }
        }

        for(int i =0;i<n;i++)
        {
            for(int j = 0;j < 2*n+m-2-1;j++)
            {
                cout << mmp[i][j] << ' ';
            }
            cout <<  mmp[i][2*n+m-2-1] << endl;
        }
        cout << endl;
    }
    return 0;
}

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值