0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-24 01:28:49 +00:00

P8032 [COCI2015-2016#7] Nizovi

R66531189
This commit is contained in:
Baoshuo Ren 2022-01-10 18:35:25 +08:00
parent 6985fa9b17
commit 1cf8422816
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

37
Luogu/P8032/P8032.cpp Normal file
View 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;
}