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.
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').
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 g h n i mo jl p k q ......... r j [/pre]程序代码:#include <iostream> #include <stdio.h> #include <cstring> using namespace std; char mapp[11][11]; int main() { char a='a'; for(int n=3;n<=10;n++) { memset(mapp,0,sizeof(mapp)); for(int i=0;i<n;i++) { if(a>'z') a-=26; mapp[i][0]=a++;//重点理解,把复杂问题简单化 } for(int i=n-2;i>=1;--i) //逆对角线上 { if(a>'z') a-=26; mapp[i][n-i-1]=a++; } for(int i=0;i<=n-1;i++) //最右一列 { if(a>'z') a-=26; mapp[i][n-1]=a++; } for(int i=0;i<n;i++) //没有的标记为空格 { for(int j=0;j<n;j++) { if(mapp[i][j]==0) printf(" "); else printf("%c",mapp[i][j]); } printf("\n"); } } return 0; }//思路非常好