题解 | #字符金字塔#
字符金字塔
http://www.nowcoder.com/practice/0fae60c3b5c64699b7c0f031c2187dde
#include <iostream> using namespace std; int main() { char c; cin >> c; int space = 4; int n=5; for(int i = 1;i <= n;i++){ for(int j = 0;j < space;j++) cout<<" "; int count = i+i-1; bool flag = true; for(int k=0;k<count;k++){ if(flag){ cout<<c; if(k==count-1) cout<<" "; }else cout<<" "; flag = !flag; } cout<<endl; space--; } return 0; }