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 a through z. Before evaluation, the initial values of these variables are a = 1, b = 2, ..., z = 26.
The operators allowed are addition and subtraction (binary + and -), with their known meaning. So, the expression a + c - d + b has the value 2 (1 + 3 - 4 + 2). Additionally, ++ and –- operators are allowed in the input expression too, which are unary operators, and may come before or after variables. If the ++ operator comes before a variable, then that variable\'s value is increased (by one) before the variable\'s value is used in calculating the value of the whole expression. Thus the value of ++ c - b is 2. When ++ comes after a variable, that variable is increased (by one) after its value is used to calculate the value of the whole expression. So, the value of the c ++ - b is 1, though c is incremented after the value for entire expression is computed; its value will be 4 too. The -- operator behaves the same way, except that it decreases the value of its operand.
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 ++ a + b ++ is the same as computing a = a + 1, result = a + b, and b = b + 1.
2 a+b c+f--+--a
Expression: a+b value = 3 a = 1 b = 2 Expression: c+f--+--a value = 9 a = 0 c = 3 f = 5