8000 Create 2448_1.cpp · hackerman91/basic-algo-lecture@2b7ccef · GitHub
[go: up one dir, main page]

Skip to content

Commit 2b7ccef

Browse files
authored
Create 2448_1.cpp
1 parent 5b2480c commit 2b7ccef

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

0x0B/solutions/2448_1.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
void printStar(int n, int i, int j) {
5+
if (j <= 2*i)
6+
if (n == 3 && !(i == 1 && j == 1)) cout << '*';
7+
else printStar(n/2, i%(n/2), j%n);
8+
else cout << ' ';
9+
}
10+
11+
int main() {
12+
ios::sync_with_stdio(0);
13+
cin.tie(0);
14+
int n;
15+
cin >> n;
16+
for (int i = 0; i < n; i++) {
17+
cout << string(n-i-1, ' ');
18+
for (int j = 0; j <= n+i; j++)
19+
printStar(n, i, j);
20+
cout << '\n';
21+
}
22+
}

0 commit comments

Comments
 (0)
0