您的位置:首页 > 其它

HDOJ 4706 Children's Day

2015-12-18 12:27 204 查看


Children's Day

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 1643 Accepted Submission(s): 1053



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.


暴力
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{
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;
}


#include <stdio.h>
#include <string.h>
int main(){
char ch[30]="abcdefghijklmnopqrstuvwxyz"; //将要输出的字符存到数组里
char map[15][15];
int cnt = 0;
for(int i=3;i<=10;i++){ //规模
memset(map,' ',sizeof(map)); //注意每次都要清空
for(int j=0;j<i;j++){//最左边一列
map[j][0] = ch[cnt%26];
cnt++;
}
for(int j=i-2;j>=1;j--){ //对角线
map[j][i-j-1]=ch[cnt%26];
cnt++;
}
for(int j=0;j<i;j++){ //最右边一列
map[j][i-1]=ch[cnt%26];
cnt++;
}
for(int j=0;j<i;j++){ //输出
for(int k=0;k<i;k++){
printf("%c",map[j][k]);
}
printf("\n");
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: