Using the procedures done in the exercises RACI1, RACI2 and RACI3, your task is to write a program that reads a sequence of rational numbers and operations and prints the result after each operation.
Input consists of a line with an initial rational, followed by a
sequence of lines, each one with a pair operation/rational. As in the
exercise RACI2, each
rational is given by a pair of integer numbers, the second integer is
not zero. The operations can be “add”,
“substract”, “multiply” or
“divide”. In this last case, the second rational is not
zero.
Your program must print the initial rational, followed by the accumulated result of each operation. Each rational number must be in a different line.
Input
1 2 add 5 2 substract 2 1 multiply 10 1 divide 3 1
Output
1/2 3 1 10 10/3
Input
3 -6 substract 0 5 add -2 -4 divide 1 1
Output
-1/2 -1/2 0 0