Codevs 4650 broken Keyboard (linked list)

Source: Internet
Author: User

/*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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.