Shun+Git

code Rational DIVIDE(Rational r){if(r.den!=0){return Rational(num*r.den,den*r.num);} else {return Rational(0,0);}}

Rational MULTIPLY(Rational r){if(r.den!=0){return Rational(num*r.num,den*r.den);} else {return Rational(0,0);}}

Rational ADD(Rational r){if(r.den!=0){return Rational((den==r.den)?(num+r.num):(num*r.den)+(r.num*den),(den==r.den)?den:(den*r.den));} else {return Rational(0,0);}}

Rational SUBTRACT(Rational r){if(r.den!=0){return Rational((den==r.den)?(num-r.num):(num*r.den)-(r.num*den),(den==r.den)?den:(den*r.den));} else {return Rational(0,0);}}

void Simplify {   int i=2, p=0; if(num<0){num=0-num; p++;} if(den<0){den=0-den; p++;} while(i<=((num<den)?num:den)){if(!(num%i||den%i)){num=num/i; den=den/i;} else {i++;}} if(p==1){num=0-num;} } code