#include <stdio.h>[/size]
int main()
{
//先列出26个字符数组
int A[26];
int a;
int b='A';
int k = 0;
for (a= 0; a < 26; a++,k++)
{
A[k] = b++;
}
//根据用户的输入,倒推前面个数(打印的行数)
char d;
int c;
printf("请输入一个大写字母:\n");
scanf("%c", &d);
while (d < 'A' || d>'Z')
{
printf("输入的内容不是一个大写字母,请重新输入:\n");
scanf("%cgetchar();", &d);
}
printf("\n");
c = d - (65-2);//为什么要减2不知道,debug试出来的。。。。。
//开始循环打印
int i,j,p;
for (i=1; i < c; i++)
{
for (j = 0,k=0; j < i-1; j++,k++)
{
printf("%c",A[k]);
}
for (p = 0; p < i;p++,k--)
{
printf("%c", A[k]);
}
printf("\n\n");
}
return 0;
}
int val = 0;
while (val < 'A' || val > 'Z') {
printf("请输入大写字母:\n");
val = _getch();
}
printf("---> %c\n", val);
//直到显示的最大值达到val
int maxshow = 'A';
while (maxshow <= val) {
int step = 1;
for (int out = 'A'; out <= maxshow; out++) printf("%c", out);
for (int out = maxshow - 1; out >= 'A'; out--) printf("%c", out);
printf("\n\n");
maxshow++;
}