//读了很久都找不出这题的公式,最后只有百度了!哎,笨啊!
#include <iostream>
#include <math.h>
using namespace std;
double d, w, age, temp;
int main()
{
int num=1;
while (scanf("%lf %lf", &w, &d), w&&d)
{
printf("Sample #%d\n", num++);
temp = d/w/810.0;
temp = log(temp);
age = temp/log(0.5)*5730.0;
if (age < 10000)
{
temp = int(age/100.0+0.5);
age = temp*100.0;
}
else
{
temp = int(age/1000.0+0.5);
age = temp*1000.0;
}
printf("The approximate age is %.lf years.\n\n", age);
}
return 0;
}zoj 1242 Carbon Dating
最新推荐文章于 2025-12-15 16:46:58 发布
本文提供了一段使用C++实现的物理公式计算代码实例,通过输入宽度和密度,计算并输出样本编号、年龄等物理参数。代码涉及公式计算、数值运算和条件判断,展示了C++在科学计算领域的应用。
122

被折叠的 条评论
为什么被折叠?



