hduoj 4706 Children's Day 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4706
Children's Day
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 32768/32768 K (Java/Others)
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 eYour 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').
bdf
c g
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 m o
j l p
k q
.........
r j
Hint
Not all the resultsare listed in the sample. There are just some lines. The ellipsis expresseswhat you should write.
Source
分析:
输出由字符组成的‘N’ , 三到十的大小。(模拟一下就可以啦)
AC代码:
1 #include<cstdio> 2 #include<cstring> 3 using namespace std; 4 char map[15][15]; 5 int main() { 6 int k = 0; 7 for(int n = 3;n <= 10;n++) { 8 9 //memset(map,'\n',sizeof(map)); 10 for(int i = 0;i <= n;i++) { 11 for(int j = 0;j < n;j++) { 12 if(i == 0 || i == n - 1 || i + j == n - 1) { 13 map[j][i] = k % 26 + 'a'; 14 k++; 15 } else if(i == n) { 16 map[j][i] = '\0'; 17 } else map[j][i] = ' '; 18 } 19 } 20 21 for(int i = 0;i < n;i++) 22 printf("%s\n",map[i]); 23 } 24 return 0; 25 }
悠游天地间 all rights reserved. © 2013 -- 1 << 64