bool isCurious(Rational r) { r = r.abs(); unsigned a, b, x, y; // ab/xy a = r.n() / 10; b = r.n() % 10; x = r.d() / 10; y = r.d() % 10; if((a == b && x == y)) { return false; } bool curious = false; if(x) curious = curious || (r == Rational(b, x) && a == y); if(y) curious = curious || (r == Rational(a, y) && b == x); if(curious) r.print(); return curious; }
// print rational r followed by a newline void prrat(Rational r) { cout << r.n() << "/" << r.d() << endl; }