File tree Expand file tree Collapse file tree 1 file changed +63
-0
lines changed
Expand file tree Collapse file tree 1 file changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ #include < iostream>
2+ using namespace std ;
3+
4+ int main () {
5+ int n;
6+ cin >> n;
7+
8+ // Upper half
9+ for (int i = 1 ; i <= n; i++) {
10+ // Left wing
11+ for (int j = 1 ; j <= i; j++) {
12+ if (j == 1 || j == i)
13+ cout << " *" ;
14+ else
15+ cout << " " ;
16+ }
17+
18+ // Spaces between wings
19+ int spaces = 2 * (n - i);
20+ for (int j = 1 ; j <= spaces; j++) {
21+ cout << " " ;
22+ }
23+
24+ // Right wing
25+ for (int j = 1 ; j <= i; j++) {
26+ if (j == 1 || j == i)
27+ cout << " *" ;
28+ else
29+ cout << " " ;
30+ }
31+
32+ cout << endl;
33+ }
34+
35+ // Lower half
36+ for (int i = n; i >= 1 ; i--) {
37+ // Left wing
38+ for (int j = 1 ; j <= i; j++) {
39+ if (j == 1 || j == i)
40+ cout << " *" ;
41+ else
42+ cout << " " ;
43+ }
44+
45+ // Spaces between wings
46+ int spaces = 2 * (n - i);
47+ for (int j = 1 ; j <= spaces; j++) {
48+ cout << " " ;
49+ }
50+
51+ // Right wing
52+ for (int j = 1 ; j <= i; j++) {
53+ if (j == 1 || j == i)
54+ cout << " *" ;
55+ else
56+ cout << " " ;
57+ }
58+
59+ cout << endl;
60+ }
61+
62+ return 0 ;
63+ }
You can’t perform that action at this time.
0 commit comments