提交时间:2025-07-13 21:33:04

运行 ID: 331779

#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 << " "; } cout << "*"; if(i > 1) { for(int j = 1; j <= 2*(i-1)-1; j++){ cout << " "; } cout << "*"; } cout << endl; } // 下半部分 for(int i = n-1; i >= 1; i--) { for(int j = 1; j <= n - i; j++){ cout << " "; } cout << "*"; if(i > 1) { for(int j = 1; j <= 2*(i-1)-1; j++){ cout << " "; } cout << "*"; } cout << endl; } return 0; }