水题。。模拟公式
humidex = temperature + h h = (0.5555)× (e - 10.0) e = 6.11 × exp [5417.7530 × ((1/273.16) - (1/(dewpoint+273.16)))]where exp(x) is 2.718281828 raised to the exponent x .
#include "stdio.h"
#include "string.h"
#include "math.h"
int main()
{
double hh,t,e,h,a,b,d;
char ch1,ch2;
while (scanf("%c",&ch1)!=EOF)
{
if (ch1=='E') break;
scanf("%lf %c %lf",&a,&ch2,&b);
getchar();
if ( (ch1=='T' || ch1=='D') && (ch2=='T' || ch2=='D') )
{
if (ch1=='T') { t=a; d=b;}
else {t=b; d=a;}
e=6.11*pow(2.718281828,(5417.7530*((1/273.16)-(1/(d+273.16)))));
h=(0.5555)*(e-10.0)+t;
printf("T %.1lf D %.1lf H %.1lf\n",t,d,h);
}
if ( (ch1=='T' || ch1=='H') && (ch2=='T' || ch2=='H') )
{
if (ch1=='T') { t=a; h=b;}
else { t=b; h=a;}
e=(h-t)/0.5555+10.0;
e/=6.11;
e=log(e);
e/=5417.7530;
e=1/273.16-e;
d=1/e;
d-=273.16;
printf("T %.1lf D %.1lf H %.1lf\n",t,d,h);
}
if ( (ch1=='H' || ch1=='D') && (ch2=='H' || ch2=='D') )
{
if (ch1=='H') {h=a; d=b;}
else {h=b; d=a;}
e=6.11*pow(2.718281828,(5417.7530*((1/273.16)-(1/(d+273.16)))));
hh=(0.5555)*(e-10.0);
t=h-hh;
printf("T %.1lf D %.1lf H %.1lf\n",t,d,h);
}
}
return 0;
}