-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP2529.cpp
54 lines (45 loc) · 909 Bytes
/
P2529.cpp
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
48
49
50
51
52
53
54
#include <iostream>
using namespace std;
char arr[10] = {};
int k;
void max_solve() {
int num = 9;
int cnt = 0;
for(int i = 0; i <= k; i++) {
if(arr[i] == '<') cnt++;
else {
for(int j = num - cnt; j <= num; j++) {
cout << j;
}
num = num - cnt - 1;
cnt = 0;
}
}
}
void min_solve() {
int num = 0;
int cnt = 0;
for(int i = 0; i <= k; i++) {
if(arr[i] == '>') cnt++;
else {
for(int j = num + cnt; j >= num; j--) {
cout << j;
}
num = num + cnt + 1;
cnt = 0;
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> k;
for(int i = 0; i < k; i++) {
cin >> arr[i];
}
max_solve();
cout << "\n";
min_solve();
return 0;
}