题解 | #牛牛的字符菱形#
牛牛的字符菱形
http://www.nowcoder.com/practice/11a5040fa894430f9d25fda1be37ddc8
#include <iostream>
#include <cmath>
using namespace std;
int main(){
int n = 5;
int m = (n + 1) / 2;
char c;
cin>>c;
for(int i=0; i<n; i++){
for(int j=0; j<abs(m-(i+1)); j++){
cout<<" ";
}
for(int j=0; j<n-abs((m-(i+1)))*2; j++){ #判断距离中间一行的距离,决定打印几个字符
cout << c;
}
cout<<endl;
}
return 0;
}