#include<bits/stdc++.h>
using namespace std;
string s;
string ans;
string tmp;
int main() {
cin >> s;
ans = "";
tmp = "";
int len = s.size();
int flag = 0;
for(int i = 0; i < len; i++) {
if (s[i] == '[' || s[i] == ']') {
if (flag == 0) {
ans += tmp;
} else {
ans = tmp + ans;
}
tmp="";
if (s[i] == '[')
flag = 1;
else
flag = 0;
} else {
tmp += s[i];
}
}
if (flag == 0) {
ans += tmp;
} else {
ans = tmp + ans;
}
cout<<ans;
return 0;
}
评论区