HDU 4706 Children's Day(简单模拟)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4706

题目大意:要用‘a’-‘z’ 26个小写字母输出倒着写得字母'N'的形状,例如 

a e
bdf
c g

就是大小为3的N。输出大小为3-10的所有N的形状,a-z的使用是连续并且周期循环的。

Sample Output
a e
bdf
c g
h  n
i mo
jl p
k  q
.........
r        j

代码如下:

 1 # include<iostream>
 2 # include<cstdio>
 3 using namespace std;
 4 
 5 int main()
 6 {
 7     int i,j,k;
 8     int ans = 0;
 9     for(i=3; i<=10; i++)
10     {
11         for(j=1; j<=i; j++)
12         {
13             printf("%c",ans+'a');
14             for(k=1; k<=i-j-1; k++)
15                 printf(" ");
16             if(j!=1 && j!=i)
17                 printf("%c",(ans+2*(i-j))%26+'a');
18             for(k=1; k<=j-2; k++)
19                 printf(" ");
20             printf("%c",(ans+2*i-2)%26+'a');
21             ans ++;
22             ans %= 26;
23             printf("
");
24         }
25         ans += i+i-2;
26         ans %= 26;
27         // printf("
");
28     }
29     return 0;
30 }
原文地址:https://www.cnblogs.com/acm-bingzi/p/3317543.html