From 1cf8422816fe20b411df3fa2b5b2622abdd1a2cb Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Mon, 10 Jan 2022 18:35:25 +0800 Subject: [PATCH] P8032 [COCI2015-2016#7] Nizovi R66531189 --- Luogu/P8032/P8032.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Luogu/P8032/P8032.cpp diff --git a/Luogu/P8032/P8032.cpp b/Luogu/P8032/P8032.cpp new file mode 100644 index 00000000..33b780c1 --- /dev/null +++ b/Luogu/P8032/P8032.cpp @@ -0,0 +1,37 @@ +#include +#include + +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; +}