#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
char str[] = "(20*(5+(7*2)))+((2+8)*(3+6*9))";
char *copy = strdup(str);
char *delim = "*+()";
char *res
= strtok( str
, delim
); while (res) {
int from
= res
-str
+strlen(res
); int to
= res
!= NULL
? res
-str
: strlen(copy
); printf("%.*s\n", to
-from
, copy
+from
); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHN0cmluZy5oPgoKaW50IG1haW4odm9pZCkgewogICAgY2hhciBzdHJbXSA9ICIoMjAqKDUrKDcqMikpKSsoKDIrOCkqKDMrNio5KSkiOwogICAgY2hhciAqY29weSA9IHN0cmR1cChzdHIpOwogICAgY2hhciAqZGVsaW0gPSAiKisoKSI7CiAgICBjaGFyICpyZXMgPSBzdHJ0b2soIHN0ciwgZGVsaW0gKTsKICAgIHdoaWxlIChyZXMpIHsKICAgIAlpbnQgZnJvbSA9IHJlcy1zdHIrc3RybGVuKHJlcyk7CiAgICAgICAgcmVzID0gc3RydG9rKCBOVUxMLCBkZWxpbSApOwogICAgICAgIGludCB0byA9IHJlcyAhPSBOVUxMID8gcmVzLXN0ciA6IHN0cmxlbihjb3B5KTsKICAgICAJcHJpbnRmKCIlLipzXG4iLCB0by1mcm9tLCBjb3B5K2Zyb20pOwogICAgfQogICAgZnJlZShjb3B5KTsKICAgIHJldHVybiAwOwp9