思路:
代码:
#include<iostream>
using namespace std;
int main() {
int n,col;
char c;
cin >> n>>c;
if (n % 2 == 0) col = n / 2;
else col = n / 2 + 1;
for (int i = 0; i < col; i++) {
if (i == 0 || i == col - 1) {
for (int j = 0; j < n; j++) {
cout << c;
if (j == n - 1)
cout << endl;
}
}
else {
for (int j = 0; j < n; j++) {
if (j == 0)
cout << c;
else if (j == n - 1)
cout << c << endl;
else
cout << " ";
}
}
}
system("pause");
return 0;
}