本人菜鸟,刚学C,问个简单的C语言题目

来源:百度知道 编辑:UC知道 时间:2024/06/10 16:14:51
接收用户输入的一个大写字母,如“C”,要求输出如下字母金字塔,其中“_”代表空格:
__A
_ABA
ABCBA

具体要求:
(1) 容许接收多次输入,直到输入为“0 (零)”;
(2) 如果输入非大写字母,则给出提示,并要求重新输入;

#include<stdio.h>
#include<stdlib.h>

void main(void)
{
char in;
int i,j,height;
while(1)
{
in=getchar();
getchar();
if(in=='0')
break;
else if(in<'A' || in>'Z')
{
printf("Wrong input, please retry.\n");
continue;
}
else
{
system("cls");//清屏
height=in-'A'+1;

for(i=0;i<height;i++)
{
in='A';
//输出空格
for(j=0;j<height-i-1;j++)