ACSL '09 Practice P6 - Expression

View as PDF

Submit solution

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 16M

Problem types
Allowed languages
ALGOL 68, Assembly, Brain****, C, C++, COBOL, Forth, Fortran, Java, Lua, Text, Turing
ACSL Practice 2009

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)))

Constraints

The length of the expression will be at most 70 characters.

The expression will never be larger than 10^8.

Sample Input 1

5*(3+3)-2-2

Sample Output 1

26

Sample Input 2

5*3*4/-7

Sample Output 2

-8

Comments

There are no comments at the moment.