Read a rational number (1)

Write a procedure

        void read_rational(int& num, int& den);

to read a rational number given in the form “numerator”/“denominator”,
and store these two values in @num@ and @den@, respectively.
Additionally, you must remove all common factors from @num@ and @den@.
For instance, if the input has

    66/12

the values after the call must be @num@  = 11 and @den@  = 2.

Precondition

1≤ @num@  ≤ 10⁹ and 1≤ @den@  ≤ 10⁹

Observation

You only need to submit the required procedure; your main program will
be ignored.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T11:34:30.215Z

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