Created
July 14, 2019 06:39
-
-
Save z-rui/50ab273e13f8fd29c67bfa6043d1c6ce to your computer and use it in GitHub Desktop.
Expand "2[ab3[c]]" into "abcccabccc"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
char*f(char*s){char*t;int n;for(t=s;*t;t++)if(*t==']')break; | |
else if(*t>>4==3){for(n=*(s=t++)-48;*t>>4==3;n=n*10+(*t++-48)); | |
if(*t=='[')for(s=t+1;n--;t=f(s));else for(t--;s<=t;putchar(*s++));} | |
else putchar(*t);return t;}int main(int c,char**v){f(v[1]);} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment