/*have never been attached to the list (well, honestly, the main thing is to look at the board is the pointer on the T.T) This problem is based on the concept of linked list array simulation pointer encountered problems is running running the cursor jump to the front or jump to the back we use next to store each point where the next point So that we can not only to the beginning and end of the insertion in the middle of any place is OK, the problem of data range of the description of the small 0.0*/#include<iostream>#include<cstdio>#include<cstring>#defineMAXN 100010using namespacestd;intNOW,LAST,L,NEXT[MAXN];CharS[MAXN];intMain () { while(SCANF ("%s", s+1) ) {next[0]=0;//because the next part will be assigned, so you don't have to memset it again .L=strlen (s+1); now=last=0; for(intI=1; i<=l;i++) { if(s[i]=='[') {now=0;Continue;} if(s[i]==']') {now=last;Continue;} Next[i]=next[now];next[now]=i;//I insert now back if(now==last) last=i;now=i; } for(inti=next[0];i;i=Next[i]) printf ("%c", S[i]); printf ("\ n"); } return 0;}
Codevs 4650 broken Keyboard (linked list)