#include <iostream> using namespace std; int main() { int n; cin >> n; // 打印上半部分 for (int i = 0; i < n; ++i) { // 打印左侧空格 for (int j = 0; j < n - i - 1; ++j) { cout << " "; } // 打印左侧星号 cout << "*"; // 打印中间空格 for (int j = 0; j < 2 * i + (n - 2); ++j) { if (i == 0) { cout << "*"; } else { cout << " "; } } // 打印右侧星号 if (i != 0) { cout << "*"; } cout << endl; } // 打印下半部分 for (int i = n - 2; i >= 0; --i) { // 打印左侧空格 for (int j = 0; j < n - i - 1; ++j) { cout << " "; } // 打印左侧星号 cout << "*"; // 打印中间空格 for (int j = 0; j < 2 * i + (n - 2); ++j) { cout << " "; } // 打印右侧星号 if (i != 0) { cout << "*"; } cout << endl; } return 0; } /************************************************************** Problem: 1011 User: fuyijun Language: C++ Result: Wrong Answer ****************************************************************/