Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: Expression Evaluator
Description This problem is about evaluating some C-style expressions. The expressions to be evaluated will contain only simple integer variables and a limited set of operators; there will be no constants in the expressions. There are 26 variables in the program, named by lower case letters The operators allowed are addition and subtraction (binary + and -), with their known meaning. So, the expression More formally, an expression is evaluated in the following manner: - Identify every variable that are preceded by ++. Write an assignment statement for incrementing the value of each of them, and omit the ++ from before that variable in the expression.
- Do similarly for the variables with ++ after them.
- At this point, there is no ++ operator in the expression. Write a statement evaluating the remaining expression after the statements determined in step 1, and before those determined in step 2.
- Execute the statements determined in step 1, then those written in step 3, and finally the one written in step 2.
This way, evaluating ++ Input The first line of the input contains a single integer Output For each test case, write each expression as it appears in the input (exactly), then write the value of the complete expression. After this, on separate lines, write the value of each variable after evaluating the expression (write them in sorted order of the variable names). Write only the values of the variables that are used in the expressions. To find out about the output format, follow the style used in the sample output below. Sample Input 2 a+b c+f--+--a Sample Output Expression: a+b value = 3 a = 1 b = 2 Expression: c+f--+--a value = 9 a = 0 c = 3 f = 5 Source |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator