自学编程,做出一道自认难题。
#include <stdio.h>int main(void) {
int i, j, sum, m, n;
char ch;
printf("Please enter a character:");
scanf("%c", &ch);
sum = ch - 'A' + 1; //总行数
for (i = 1; i <= sum; i++) {
for (j = 0; j < sum - i; j++)
printf(" ");
for (m = 1; m <= i; m++)
printf("%c", 'A' - 1 + m);
for (n = 1; n < i; n++)
printf("%c", 'A' - 2 + m - n);
printf("\n");
}
return 0;
}