Пример #1
0
Rational operator^(Rational num1, int power)
{
    int c = pow(num1.getB(), power);
    int d = pow(num1.getA(), power);
    return Rational(d, c);
}
Пример #2
0
Rational operator*(Rational num1, Rational num2)
{
    int c = num1.getB() * num2.getB();
    int d = num1.getA() * num2.getA();
    return Rational(d, c);
}
Пример #3
0
Rational operator*(int num2, Rational num1)
{
    int c = num1.getB();
    int d = num2*num1.getA();
    return Rational(d, c);
}
Пример #4
0
Rational operator-(Rational num1, Rational num2)
{
    int c = LCM(num1.getB(), num2.getB());
    int d = (c / num1.getB())*num1.getA() - (c / num2.getB())*num2.getA();
    return Rational(d, c);
}
Пример #5
0
Rational operator-(Rational num1, int num2)
{
    int c = num1.getB();
    int d = num1.getA() - num2*num1.getB();
    return Rational(d, c);
}