-
-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathchristmas_tree.cpp
More file actions
47 lines (35 loc) · 804 Bytes
/
Copy pathchristmas_tree.cpp
File metadata and controls
47 lines (35 loc) · 804 Bytes
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
42
43
44
45
46
47
// https://www.urionlinejudge.com.br/judge/en/problems/view/1768
#include <iostream>
#include <string>
using namespace std;
int main() {
int n, mid, start, end;
while (cin >> n) {
mid = n / 2;
start = mid;
end = mid;
for (int i = 0; i < mid + 1; i++) {
for (int j = 0; j < n; j++) {
if (j >= start && j <= end) cout << "*";
else if (j > end) break;
else cout << " ";
}
cout << endl;
start--;
end++;
}
for (int i = 0; i < n; i++) {
if (i == mid) cout << "*";
else if (i > mid) break;
else cout << " ";
}
cout << endl;
for (int i = 0; i < n; i++) {
if (i == mid || i == mid-1 || i == mid+1) cout << "*";
else if (i > mid+1) break;
else cout << " ";
}
cout << endl << endl;
}
return 0;
}