能被小曹称赞为优美,很想看看它是个什么样子。
也凑个热闹,不过我这段代码还当不起优美二字,只当是块砖吧。
程序代码:
也凑个热闹,不过我这段代码还当不起优美二字,只当是块砖吧。
程序代码:#include<stdio.h>
void cal(int a, int b, int c, int d, int n)
{
int e, f, t, t1, t2;
if(n <= 0) return;
e = a * n / b + 1;
f = n;
if(e * d >= c * f){ cal(a, b, c, d, n - 1); return;}
for(t1 = e, t2 = f; t = t1 % t2; t1 = t2, t2 = t);
e /= t2;
f /= t2;
cal(a, b, e, f, n);
printf("%d/%d\n", e, f);
cal(e, f, c, d, n);
}
int main()
{
cal(1, 2, 2, 3, 10);
return 0;
}
重剑无锋,大巧不工








