Exemplo n.º 1
0
int main() {
    Rat a = Rat(1,2);
    Rat b = Rat(3,4);
    
    Rat add = a.operator+(b);
    cout << add.getN() << "/" << add.getD() << endl;
    
    Rat mult = a.operator*(b);
    cout << mult.getN() << "/" << mult.getD() << endl;
    
    Rat div = a.operator/(b);
    cout << div.getN() << "/" << div.getD() << endl;
}
Exemplo n.º 2
0
 void lowestTerms(Rat &t) {
     int x = t.gcd(t.getN(), t.getD());
     t.n/=x;
     t.d/=x;
 }