ACSL Practice 2009

Task 6: Expression

Given an arithmetic expression, output its value.

The expression will be given without spaces, but it may contain the four operators (+, -, /, *) and brackets ().
The regular order of evaluation applies. Division here is regarded as integer division.
(There will be no strange or invalid expressions, like 5(2(2)))

Sample Input

5*(3+3)-2-2

Sample Output

26

Sample Input 2

5*3*4/-7

Sample Output 2

-8

All Submissions
Best Solutions


Point Value: 15 (partial)
Time Limit: 2.00s
Memory Limit: 16M
Added: May 19, 2009

Languages Allowed:
C++03, PAS, C, ASM, C++11

Comments (Search)

Why is java not allowed on this question?

Maybe because of Java's built-in ScriptEngine that is able to parse and evaluate a math expression from a string?

Wouldn't something with a negative sign be considered a strange expression since it's hard for a program to tell if it's a negative sign or subtraction?