forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path302.cpp
More file actions
51 lines (47 loc) · 831 Bytes
/
302.cpp
File metadata and controls
51 lines (47 loc) · 831 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
48
49
50
51
//ac
#include <iostream>
#include <string>
#include <vector>
using namespace std;
char upper(char c) {
if (c >= 'A' && c <= 'Z') return c;
return c - 'a' + 'A';
}
char lower(char c) {
if (c >= 'a' && c <= 'z') return c;
return c - 'A' + 'a';
}
int main() {
string str;
cin >> str;
string ret;
vector<int> sign;
for (int i = 0; i < str.length(); ++i) {
if (str[i] == '<') {
if (str[i + 1] == '/') {
if (str[i + 2] == 'U') i += 4;
else i += 6;
sign.pop_back();
} else {
if (str[i + 1] == 'U') {
sign.push_back(1);
i += 3;
}
else {
sign.push_back(0);
i += 5;
}
}
} else {
if (sign.empty()) {
ret += str[i];
} else if (sign.back() == 1) {
ret += upper(str[i]);
} else {
ret += lower(str[i]);
}
}
}
cout << ret << endl;
return 0;
}