mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 18:48:48 +00:00
P8032 [COCI2015-2016#7] Nizovi
R66531189
This commit is contained in:
parent
6985fa9b17
commit
1cf8422816
37
Luogu/P8032/P8032.cpp
Normal file
37
Luogu/P8032/P8032.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
std::string s, w, p;
|
||||
|
||||
int main() {
|
||||
cin >> s;
|
||||
for (int i = 0; i < s.size(); i++) {
|
||||
char c = s[i];
|
||||
if (c == '{') {
|
||||
cout << p << c << endl;
|
||||
p += " ";
|
||||
} else if (c == ',') {
|
||||
if (s[i - 1] == '}') continue;
|
||||
cout << p << w << c << endl;
|
||||
w.clear();
|
||||
} else if (c == '}') {
|
||||
if (!w.empty()) {
|
||||
cout << p << w << endl;
|
||||
w.clear();
|
||||
}
|
||||
p.erase(0, 2);
|
||||
cout << p << c;
|
||||
if (i + 1 != s.size() && s[i + 1] != '}') {
|
||||
cout << ',';
|
||||
}
|
||||
cout << endl;
|
||||
} else {
|
||||
w.push_back(c);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user