Using the procedures done in the exercises : “”, : “” and : “”, your task is to write a program that reads a sequence of rational numbers and operations
r_{0} o_{1} r_{1} o_{2} r_{2} … o_{n − 1} r_{n − 1} o_{n} r_{n} , |
and prints the result after each operation.
Input
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 : “”, 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.
Output
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