** 求助,样例可以过,但交上去就是不对 **
using namespace std;
string b;
struct bj
{
char cr;
bj *nxt;
};
int main()
{
while(cin>>b)
{
bj *p,*tail,*head,*q;
head=p=q=tail=new bj;
p->nxt=NULL;
for(int i=0;i<b.length();i++)
{
if(b[i]=='[')
{
q=p=head;
}
else if(b[i]==']')
{
q=p=tail;
}
else
{
p=new bj;
p->cr=b[i];
p->nxt=q->nxt;
q->nxt=p;
q=p;
if(p->nxt==NULL)
{
tail=p;
}
}
}
p=head->nxt;
while(p!=NULL)
{
cout<<p->cr;
p=p->nxt;
}
cout<<endl;
}
}