#C14552. Evaluate Arithmetic Expression
Evaluate Arithmetic Expression
Evaluate Arithmetic Expression
You are given a mathematical expression E that consists of positive and negative integers, the operators \(+\), \(-\), \(*\), and \(/\), and parentheses which may be nested.
Your task is to evaluate the expression according to the standard operator precedence.
Note:
- If a division by zero occurs during the evaluation, output
Error: Division by zero
. - The expression might contain extra whitespace which should be ignored.
Examples:
- Input:
3 + 5
→ Output:8.0
- Input:
10 + 2 * 6
→ Output:22.0
- Input:
(5 + 3) * 12 / 3
→ Output:32.0
- Input:
100 / (3 - 3)
→ Output:Error: Division by zero
inputFormat
The input is provided via standard input (stdin) as a single line containing the expression E. The expression may include spaces.
outputFormat
Output the result of the evaluation to standard output (stdout). If the result is finite, output it as a floating-point number with one decimal place. If a division by zero is encountered, print exactly Error: Division by zero
.
3 + 5
8.0