请问用C语言 第一行是A第二行BBB 公式是:2N-1 A BBB CCCCCDDDDDDD #include <stdio.h> #include <conio.h> int main( void ) { unsigned int lineLength = 4; unsigned int i = 0; unsigned int j = 0; bool inputState = false; int ch = 0; unsigned int lineMaxLength = 0; unsigned int spaceLength = 0; unsigned int charLength = 0; //1.处理输入 do { printf( "请输入行数:" ); scanf( "%u", &lineLength ); if( lineLength > 26 ) { printf( "错误!行数最多为26行,请重新输入。/r/n/r/n" ); inputState = false; } else { inputState = true; } } while ( !inputState ); //2.输出 lineMaxLength = 2 * lineLength - 1; for( i = 1, ch = 'A', charLength = 1; i <= lineLength; i++, ch++, charLength += 2 ) { spaceLength = (lineMaxLength - charLength) / 2; //2.1 输出左边空格 for( j = 1; j <= spaceLength; j++ ) { printf( " " ); } //2.2 输出中间字符 for( j = 1; j <= charLength; j++ ) { printf( "%c", ch ); } printf( "/r/n" ); } //End printf( "/r/n运行结束。按任意键退出。/r/n" ); getch(); return 0; }