| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11614 | DS_2017fall_Quiz1 |
|
Description
Evaluate the value of each postfix expression.
<stack> <queue> <list> <vector> are not allowed.
You can't use any push and pop function from any library.
The header file is provided below, and you need to rename it as function.h and include it.
Remember to upload the source code (the same version as submitted to OJ) to iLMS as well.
Time Limit: 3 sec
Input
Each test case includes several lines and each line is a string of postfix expression.
You need to evaluate the value of each postfix expression.
Each operand is a digit (0 - 9), and the set of operators are: + , - , * , / , ^(指數), %(餘數,you just need to maintain integer % integer).
The length of each line is between 1 and 1,000,000 characters.
Output
Given a postfix expression: 1 2 + 3 4 + * (Note: the corresponding infix expression is (1+2)*(3+4) )
The evaluated value will be 21.
In our main.cpp , it will be 21.000.
However, you don't need to handle the output format. It is fixed to X.XXX (輸出小數點後三位)