Files
python/TangDou/Output/O9.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

20 lines
539 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
int main() {
//如果要求输入的是9行那么n=(9+1)/2=5
int i, j, n = 5;
for (i = 1; i <= n; i++) {
for (j = 1; j <= (n - i); j++) cout << " ";
for (j = 1; j <= (2 * (i - 1) + 1); j++) cout << "*";
cout << endl;
}
for (i = n - 1; i >= 1; i--) {
for (j = 1; j <= (n - i); j++) cout << " ";
for (j = 1; j <= (2 * (i - 1) + 1); j++) cout << "*";
cout << endl;
}
cout << endl;
return 0;
}