paren matching by chocobi

string c,d,s[],o;for(string i:stdin){o="";for(;i!="";i=substr(i,1)){c=substr(i,0,1);d=c=="("?")":c=="["?"]":c=="{"?"}":"";if(d>"")s.push(d);o+=c=="?"?s.pop():c;}write(o);}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page