// yukicoder: No.49 算数の宿題 // 2019.4.7 bal4u // 構文解析 #include #include char s[105]; char *num(int *n, char *p) { int k = 0; while (isdigit(*p)) k = 10 * k + (*p++ & 0xf); *n = k; return p; } int main() { int x, op, ans; char *p; scanf("%s", s); p = num(&ans, s); while (*p) { if (isdigit(*p)) { p = num(&x, p); if (op == '*') ans += x; else ans *= x; } else op = *p++; } printf("%d\n", ans); return 0; }