得到如下代码:#include
int gcd(int a, int b)
{
return b == 0 ? a : gcd (b, a%b);
}
int lcm(int a, int b)
{
return a/gcd(a, b)*b;
}
int main()
{
int a1, b1, a2, b2, lb;
while (scanf ("%d/%d %d/%d", a1, b1, a2, b2) != EOF){
lb = lcm(b1, b2);
if (lb/b1*a1 > lb/b2*a2){
printf ("%d/%d > %d/%d", a1, b1, a2, b2);
}
else if (lb/b1*a1 < lb/b2*a2){
printf ("%d/%d < %d/%d", a1, b1, a2, b2);
}
else {
printf ("%d/%d = %d/%d", a1, b1, a2, b2);
}
}
}