bLue的大写L

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/weixin_43886377/article/details/100586037

Problem Description
大家有注意到 bLue 这四个字母中只有第二个字母是大写的吗?bLue 想让他的 ‘L’ 看起来更加高大上,所以他来让你帮他写几个不同尺寸的 ‘L’ 图案。

Input
输入数据有多组(数据组数小于 20),到 EOF 结束。

对于每组数据,输入一行,包含一个整数 n (2 <= n <= 20),表示 L 的尺寸。

Output
对于每组数据,输出大写字母组成的 ‘L’ 图案,前 n-1 个字母每个占一行,后 n 个字母在一行内输出。输出的字母按照 ‘A’, ‘B’, ‘C’, ‘D’… 的顺序(‘Z’ 的下一个回到 ‘A’),每组数据的末尾额外输出一行空行。

Sample Input
2
3
5
15
Sample Output
A
BC

A
B
CDE

A
B
C
D
EFGHI

A
B
C
D
E
F
G
H
I
J
K
L
M
N
OPQRSTUVWXYZABC

Hint

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int n,i;
    char ch;
    while(scanf("%d",&n)!=EOF)
    {
        ch='A';
        for(i=1; i<=n-1; i++)
        {
            printf("%c\n",ch);
            if(ch=='Z')ch='A';
            else ch=ch+1;
        }
        for(i=1; i<=n; i++)
        {
            printf("%c",ch);
            if(ch=='Z')ch='A';
            else ch=ch+1;
        }
        printf("\n\n");
    }

    return 0;

}

猜你喜欢

转载自blog.csdn.net/weixin_43886377/article/details/100586037
l