题目连接: http://poj.org/problem?id=3299
本题为套用公式基础题。
题目大意:有 T D H 三个数值,随机给你两个数值,由公式推断出第三个数的值
humidex = temperature + h
h = (0.5555)× (e - 10.0) e = 6.11 × exp [5417.7530 × ((1/273.16) - (1/(dewpoint+273.16)))]
<pre name="code" class="cpp">#include"iostream"
#include"cmath"
#include"iomanip"
using namespace std;
int main()
{
int i;
char stype;
double n,t,d,h;
for(;;){
t = d = h = 200;
for(i = 0;i < 2;i++){
cin >> stype >> n;
if(stype == 'T')
t = n;
else if(stype == 'D')
d = n;
else if(stype == 'H')
h = n;
else
return 0;
}
if(t == 200)//exp 是e 的 x 次方
t = h - (0.555) * (6.11 * exp(5417.7530 * ((1 / 273.16) - (1 / (d + 273.16)))) - 10.0);
else if(d == 200)//log 是以 e 为底的对数
d = 1 / ((1 / 273.16) - ((log((((h - t) / 0.5555) + 10.0) / 6.11)) / 5417.7530)) - 273.16;
else
h = t + 0.5555 * (6.11 * exp(5417.7530 * ((1 / 273.16) - (1 / (d + 273.16)))) - 10.0);
cout << setprecision(1) << fixed << "T " << t << " D " << d << " H " << h << endl;
}
return 0;
}