hdu 4706:Children's Day(模拟题,模拟输出大写字母 N)

时间:2022-04-29 09:29:27

Children's Day

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


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

 

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

 

Source
 

 

Recommend
liuyiding   |   We have carefully selected several similar problems for you:   4822  4821  4820  4819  4818 

  
  模拟题
  模拟输出大写字母‘N’,‘N’由小写字母组成,输出的尺寸大小由3增加到10,每个尺寸之间没有空格。输出示例见上。
  做这样的模拟题就是要观察输出图形之间的数学关系。总结出关系之后,图形输出就很容易了。
  代码:
 
 1 #include <iostream>
 2 
 3 using namespace std;  4 
 5 int main()  6 {  7     int n;  //size
 8     int c = 1;  //该尺寸的第一个字母的序号
 9     for(n=3;n<=10;n++){ //循环尺寸
10         int i,j;  //该尺寸的第i行,和该行第j个元素
11         int c1=c%26,c2=(c+2*n-2)%26;  //分别记录每一行的第一个字母和最后一个字母序号
12         if(c1==0) c1=26; 13         if(c2==0) c2=26; 14         for(i=1;i<=n;i++){  //
15             int k=n+1-i;    //每一行中间元素的位置
16             for(j=1;j<=n;j++){   //该行每一个元素
17                 if(j==1) 18                     cout<<char(c1+'a'-1); 19                 else if(j==n) 20                     cout<<char(c2+'a'-1); 21                 else if(j==k){  //中间元素
22                     int kc = (c+n+k-2)%26; 23                     if(kc==0) kc=26; 24                     cout<<char(kc+'a'-1); 25  } 26                 else
27                     cout<<' '; 28  } 29             cout<<endl; 30             c1=(c1+1)%26,c2=(c2+1)%26; 31             if(c1==0) c1=26; 32             if(c2==0) c2=26; 33  } 34         c=(c+3*n-2)%26; 35         if(c==0) 36             c=26; 37  } 38     return 0; 39 }

 

Freecode : www.cnblogs.com/yym2013