#include <math.h>
#include <stdio.h>
int main()
{
double w,d,s,t;
int k=1;
while (scanf("%lf%lf",&w,&d),w||d)
{
s=t=log((w*810)/d)/log(2.0)*5730;
if (s<10000)
{
t=floor(t/100)*100;
s=s-t>=50?t+100:t;
}
else
{
t=floor(t/1000)*1000;
s=s-t>=500?t+1000:t;
}
printf("Sample #%d/nThe approximate age is %0.0lf years./n/n",k++,s);
}
return 0;
}
注:这个题,注意四舍五入,发现整数比较要比+0.5这种方法精确,注意