#include <iostream> using namespace std; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { // 打印左边的空格 for (int j = 1; j <= n - i; j++) { cout << " "; } // 打印左边的星号 for (int j = 1; j <= 2 * i - 1; j++) { cout << "*"; } // 打印中间的空格 for (int j = 1; j <= 2 * (n - i); j++) { cout << " "; } // 打印中间的星号 for (int j = 1; j <= 2 * i - 1; j++) { cout << "*"; } // 打印右边的空格 for (int j = 1; j <= 2 * (n - i); j++) { cout << " "; } // 打印右边的星号 for (int j = 1; j <= 2 * i - 1; j++) { cout << "*"; } cout << endl; } return 0; } /************************************************************** Problem: 1006 User: fuyijun Language: C++ Result: Accepted Time:3 ms Memory:2072 kb ****************************************************************/