描述
输入行数N,打印图形.
输入描述
输入只有一行,包括1个整数。(N<=15)
输出描述
输出有N行.
用例输入 1
3
用例输出 1
A BAB CBABC
来源
字符型
#include <bits/stdc++.h>
using namespace std;
int main() {
char t;
int n,f;
cin>>n;
for(int i=1;i<=n;i++){
t=char(65+i);
for(int j=1;j<=n-i;j++){
cout<<' ';
}
f=0;//开关未开启。
for(int j=1;j<=i*2-1;j++){
if(t=='A') f=1;//打开开关。
if(!(f)) t--;
else t++;
t=char(t);
cout<<t;
}
cout<<endl;
}
return 0;
}