问答详情
源自:6-1 数组初体验

1.1 求字母金字塔

 

a

b b

c c c

 


提问者:进阶白发 2016-11-05 18:58

个回答

  • 越飞越高
    2016-11-05 23:52:31

    #include <stdio.h>
    int main()
    {
    int times;
    int t = 0;
    int h,j;
    char n = 'A';
    printf("请输入字母的行数:");
    scanf("%d",&times);
    for(h = 1; h <= times; h++)
    {
     for(j = 1; j < times -h +1; j++)
    printf(" ");
     for(j = 1; j <= (2 * h -1) ; j++)
    printf("%c", n);
     printf("\n");
     n++;
    }
    return 0;
    }