/*************************************************************************** rational.h - description ------------------- begin : Mon Jan 17 19:41:58 CST 2004 copyright : (C) 2003 by Daniel Eric Smith email : ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include #include using namespace std; /*Don't think I need this any longer long int abs(long int u) { if(u<0) {return -1*u;} else {return u;} } */ long int gcd(long int u,long int v) { long int t; while(u>0) { if(u (rational q); bool operator<= (rational q); bool operator>= (rational q); /* INPUT/OUTPUT */ friend istream& operator>>(istream& s, rational& r); friend ostream& operator<<(ostream& s, rational r); /* OTHER */ friend rational pow(rational r, long int n); }; void rational::set(long int n, long int d) { num=n; den=d; } void rational::show() { cout < (rational q) { return(num*q.den > den*q.num); } bool rational::operator<= (rational q) { return(num*q.den <= den*q.num); } bool rational::operator>= (rational q) { return(num*q.den >= den*q.num); } /*************** * INPUT/OUTPUT * ***************/ istream& operator>>(istream& s, rational& r) { s>>r.num>>r.den; return s; } ostream& operator<<(ostream& s, rational r) { if(r.den == 1) { s <