Notice:
四舍五入 具体参考
https://blog.csdn.net/BatmannLv/article/details/121642463?spm=1001.2014.3001.5502
#include <iostream>
using namespace std;
int main(){
int n,row;
char c;
cin >> n >> c;
row = ((1.0 * n / 2) + 0.5); //行数,不乘以0.1无法实现四舍五入。做第一个除法的时候直接截断了
//row = (n+1) /2 ;
//row = n / 2 + n % 2;
for(int i = 0;i < n;i++) //第一行
cout << c;
cout << endl;
//中间
for(int i = 1;i < row - 1;i++){
cout << c;
for(int j = 1;j < n - 1;j++)
cout << " ";
cout << c << endl;
}
//最后一行
for(int i = 0;i < n;i++)
cout << c;
return 0;
}