B2005 字符三角形 题解

· · 题解

简单的输出,C++中可以用 \n 来表示换行,可以与之后的空格连续。

输出三行,模拟一下即可。

代码如下:

#include<bits/stdc++.h>
using namespace std;
char c;
int main(){
    cin>>c;
    cout<<"  "<<c<<"  \n "<<c<<c<<c<<" \n"<<c<<c<<c<<c<<c;
    return 0;
}