您的位置:首页 > 其它

HDU 4706 Children's Day(模拟啊)

2014-11-23 20:11 369 查看
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4706

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

[pre]
a e bdf c gh n
i mo
jl p
k q
.........
r j
[/pre]

Hint
Not all the resultsare listed in the sample. There are just some lines. The ellipsis expresseswhat you should write.




Source

2013 ACM/ICPC Asia Regional Online —— Warmup

代码如下:

#include <cstdio>
const int maxn = 117;
int main()
{
	char s[maxn][maxn];
	int i, j, k;
    int cont = 0;
    for(i = 3; i <= 10; i++)
    {
        for(j = 0; j < i; j++)  //全部赋值为空格  
        {
            for(k = 0;k < i;k++)
                s[j][k] = ' ';
        }
        for(j = 0; j < i; j++)//第一列
        {
            s[j][0] = 'a' + cont;
            cont = (cont+1)%26;
        }
        for(j = i-2; j > 0; j--)//副对角线
        {
            s[j][i-j-1] = 'a' + cont;
            cont = (cont+1)%26;
        }
        for(j = 0; j < i; j++)//最后一列
        {
            s[j][i-1] = 'a' + cont;
            cont = (cont+1)%26;
        }
        for(j = 0;j < i;j++)
            printf("%s\n",s[j]);
    }
	
    return 0;
}


打表代码如下:

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
char ff(char c)
{
    if(c > 'z')
        c = 'a';
    return c;
}
int main()
{
    int i, j, k, l;
    char c = 'a';
    printf("a e\nbdf\nc g\n");
    printf("h  n\ni mo\njl p\nk  q\n");
    printf("r   z\ns  ya\nt x b\nuw  c\nv   d\n");
    printf("e    o\nf   np\ng  m q\nh l  r\nik   s\nj    t\n");
    printf("u     g\nv    fh\nw   e i\nx  d  j\ny c   k\nzb    l\na     m\n");
    printf("n      b\no     ac\np    z d\nq   y  e\nr  x   f\ns w    g\ntv     h\nu      i\n");
    printf("j       z\nk      ya\nl     x b\nm    w  c\nn   v   d\no  u    e\np t     f\nqs      g\nr       h\n");
    printf("i        a\nj       zb\nk      y c\nl     x  d\nm    w   e\nn   v    f\no  u     g\np t      h\nqs       i\nr        j\n");
    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: