直接贴代码
#include<bits/stdc++.h>
using namespace std;
// 试着用一下list
int main(){
string s;
while(cin>>s) {
list<char> line;
auto it = line.begin();
for (int i = 0; i<s.length(); i++) {
char c = s[i];
if(c=='[')
it = line.begin();
else if(c==']')
it = line.end();
else {
it = line.insert(it,c);
it++;
}
}
for (it = line.begin(); it!=line.end(); it++)
cout<<*it;
s.clear();
cout<<endl;
}
return 0;
}