这是C++的写法

using namespace std;
#define int long long
#define endl '\n'
signed main(){
    std::ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    char c;cin>>c;
    for(char i='A';i<=c;i++){
        for(char j=1;j<=c-i;j++)
            cout<<" ";//输出空格
       //正序输出
        for(char k='A';k<=i;k++)
            cout<<k;
        //倒序输出
        for(char z=i-1;z>='A';z--)
            cout<<z;
        cout<<endl;
    }
    return 0;
}