
ZOJ Problem Set  1725
The author of an elementary school algebra text book has approached you to write a program to solve simple algebra equations. The author wants to use a program to avoid human errors in preparing the solutions manual. The text book author will provide a text file of the simple problems for your problem to solve. All of the problems will be in the form of an algebraic equality. The specific syntax of the problems will be an algebraic statement consisting of integer constants and the four basic arithmetic operators, an equal sign, and a variable. For example: 12  4 * 3 = x For the solutions manual the problem is not just to be solved, but solved one step at a time. For the above input line, the corresponding output would be: 12  4 * 3 = x The simple problems your program is to solve are limited to integer values with multiplication, division, addition and subtraction operations. Note that, as in the above example, the computation must follow the standard order of precedence for arithmetic operations. All multiplications and divisions are performed, from left to right, before any additions and subtractions, and then all additions and subtractions are performed from left to right. You may assume that all divisions will result in integer values.
Output for a problem should begin with the problem to be solved, then followed by one line of output after each operation. The spacing between the numbers and operations in the output is not critical. Having the correct answers and all the correct steps in the output is important. A typical input file will consist of multiple algebraic problems, each on a separate line. The output for each input problem should be separated by a single blank line in the output. The end of the file marks the end of the input.
3 * 4 + 4  1 / 1 = xyzzy
3 * 4 + 4  1 / 1 = xyzzy 12 + 2 * 12 / 2  1 = y 2 * 3 + 6  4 = r 2 * 3 + 6  4 = r Source: MidCentral USA 1996 