使用嵌套循环以下面金字塔型的格式打印大写字母
作者:互联网
>//输入E
> A
> ABA
> ABCBA
> ABCDCBA
>ABCDEDCBA
#include<stdio.h>
#include<math.h>
int main(void)
{
int line, line_all, row_blank, row_plus, row_minus;
char ch;
scanf_s("%c", &ch);
line_all = ch - 'A' + 1;
for (line=1; line <= line_all; line++)
{
for (row_blank = 0; row_blank < line_all - line; row_blank++)
printf("%c", ' ');
for (row_plus = 0; row_plus < line; row_plus++)
printf("%c", 'A' + row_plus);
for (row_minus = row_plus - 2; row_minus >= 0; row_minus--)
printf("%c", 'A' + row_minus);
printf("\n");
}
getchar();
return 0;
}
标签:printf,大写字母,嵌套循环,plus,blank,line,金字塔,minus,row 来源: https://blog.csdn.net/bokutaki/article/details/112596468