1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| #include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; for (int i = 0; i<n; i++){ for (int x= 0;x<3;x++) { for (int j = 0; j<(n - 1 - i); j++){ cout << " "; } for (int j = 0; j < 2 * i + 1; j++) { if (j == 0 || j == 2 * i) cout << "*"; else cout << " "; } for (int j = 0; j<(n - 1 - i); j++){ cout << " "; } } cout << endl; } for (int i = 0; i < n - 1; i++){ for (int x= 0;x<3;x++) { for (int j = 0; j < i + 1; j++) { cout << " "; } for (int j = 0; j < 2 * (n - 1) - (1 + 2 * i); j++){ if (j == 0 || j == 2 * (n - i - 2)) cout << "*"; else cout << " "; } for (int j = 0; j < i + 1; j++) { cout << " "; } } cout << endl; } return 0; }
|