Programming/코딩 문제 풀이
2020/04/10 코딩 문제 연습 (5단계 / 백준 10996번 - 왠지 어려운 문제) C++
갓비니
2020. 4. 10. 23:16
<10996번 문제>
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
|
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
if (n == 1) {
cout << "*" << '\n';
}
else {
for (int i = 1; i <= n * 2; i++) {
if (i % 2 == 1) {
if (n % 2 == 0) {
for (int j = 1; j <= n / 2; j++)
cout << "* ";
cout << '\n';
}
else {
for (int j = 1; j <= (n + 1) / 2; j++)
cout << "* ";
cout << '\n';
}
}
else {
if (n % 2 == 0) {
for (int j = 1; j <= n / 2; j++)
cout << " *";
cout << '\n';
}
else {
for (int j = 1; j <= (n - 1) / 2; j++)
cout << " *";
cout << '\n';
}
}
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|