题目主要是运用单向链表,主要是讲数据结构课中的链式线性表用数组表示
#include<bits/stdc++.h>
using namespace std;
string s;
int a[100005];
int main(){
while(cin>>s){
int cur=0,end=0,len=s.size();
a[0]=0;
for(int i=0;i<len;i++){
if(s[i]=='['){
cur=0;
}else if(s[i]==']'){
cur=end;
}else{//这个语句相当于是在p节点以后插入一个节点
a[i+1]=a[cur];
a[cur]=i+1;
if(cur==end){
end=i+1;
}
cur=i+1;
}
}
for(int i=a[0];i!=0;i=a[i]){
cout<<s[i-1];
}
cout<<endl;
}
}