Rational numbers (4)

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
r₀  o₁ r₁  o₂ r₂  …  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 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.

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.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T10:28:19.133Z

© Jutge.org, 2006–2026.
https://jutge.org
