Fraction Fraction::operator-(Fraction f2)
{
Fraction result;
result.numerator = ((numerator * f2.denominator) - (f2.numerator * denominator)) ;
result.denominator = (denominator * f2.denominator);
for(int i = result.numerator * result.denominator; i > 1; i--)
{
if ((result.numerator % i == 0) && (result.denominator % i == 0))
{
result.numerator = result.numerator / i;
result.denominator = result.denominator / i;
}
}
return result;
}
RnJhY3Rpb24gRnJhY3Rpb246Om9wZXJhdG9yLShGcmFjdGlvbiBmMikKewogICAgRnJhY3Rpb24gcmVzdWx0OwogICAgcmVzdWx0Lm51bWVyYXRvciA9ICgobnVtZXJhdG9yICogZjIuZGVub21pbmF0b3IpIC0gKGYyLm51bWVyYXRvciAqIGRlbm9taW5hdG9yKSkgOwogICAgcmVzdWx0LmRlbm9taW5hdG9yID0gKGRlbm9taW5hdG9yICogZjIuZGVub21pbmF0b3IpOwogICAgZm9yKGludCBpID0gcmVzdWx0Lm51bWVyYXRvciAqIHJlc3VsdC5kZW5vbWluYXRvcjsgaSA+IDE7IGktLSkKICAgIHsKICAgICAgICBpZiAoKHJlc3VsdC5udW1lcmF0b3IgJSBpID09IDApICYmIChyZXN1bHQuZGVub21pbmF0b3IgJSBpID09IDApKQogICAgICAgIHsKICAgICAgICAgICAgcmVzdWx0Lm51bWVyYXRvciA9IHJlc3VsdC5udW1lcmF0b3IgLyBpOwogICAgICAgICAgICByZXN1bHQuZGVub21pbmF0b3IgPSByZXN1bHQuZGVub21pbmF0b3IgLyBpOwogICAgICAgIH0KICAgIH0KICAgIHJldHVybiByZXN1bHQ7Cn0=