hdu 4706 Children's Day

Children's Day

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0


Problem Description
  
  
Today is Children's Day. Some children ask you to output a big letter 'N'. 'N' is constituted by two vertical linesand one diagonal. Each pixel of this letter is a character orderly. No tail blank is allowed. For example, this is a big 'N' start with 'a' and it's size is 3.
a e
bdf
c g

Your task is to write different 'N' from size 3 to size 10. The pixel character used is from 'a' to 'z' continuously and periodic('a' is reused after 'z').
 

Input
  
  
This problem has no input.
 

Output
  
  
Output different 'N' from size 3 to size 10. There is no blank line among output.
 

Sample Output
  
  

a e bdf c g h n i mo jl p k q ......... r j

 

 

#include <iostream>
#include <cstdio>

#define MAXN 11

using namespace std;

char c[MAXN][MAXN];

void output()
{
    int total = 0;
    
    for (int i = 3; i <= 10; i++)
    {
        for (int j = 1; j <= i; j++)
        {
            for (int k = 1; k <= i; k++)
            {
                if (j + k == i + 1)
                {
                    c[j][k] = 'a' + (i + (i - j) - 1 + total) % 26;
                }
                else if (k == 1)
                {
                    c[j][k] = 'a' + (j - 1 + total) % 26;
                }
                else if (k == i)
                {
                    c[j][k] = 'a' + ((i + i - 2)    + j - 1 + total) % 26;
                }
                else
                {
                    c[j][k] = '#';
                }
            }
        }
        
        total += (2 * i + (i - 2));
        
        for (int j = 1; j <= i; j++)
        {
            for (int k = 1; k <= i; k++)
            {
                if (c[j][k] == '#')
                {
                    cout << ' ';
                }
                else
                {
                    cout << c[j][k];
                }
            }
            cout << endl;
        }

    }
}

int main()
{
    std::ios::sync_with_stdio(false);
    output();
    return 0;
}


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值