1、题目类型:数论。
2、解题思路:水题。
3、注意事项:esp表示e的指数函数。
4、实现方法:
#include
<
iostream
>
#include < math.h >
#include < algorithm >
using namespace std;
int main()
{
char ch1,ch2;
double temp,dew,hum,h,e;
while (cin >> ch1)
{
temp = dew = hum = h = e = 0.0 ;
if (ch1 == ' E ' )
break ;
if (ch1 == ' T ' )
cin >> temp;
else if (ch1 == ' D ' )
cin >> dew;
else if (ch1 == ' H ' )
cin >> hum;
cin >> ch2;
if (ch2 == ' T ' )
cin >> temp;
else if (ch2 == ' D ' )
cin >> dew;
else if (ch2 == ' H ' )
cin >> hum;
if (hum == 0.0 )
{
e = 6.11 * exp( 5417.7530 * (( 1 / 273.16 ) - ( 1 / (dew + 273.16 ))));
h = ( 0.5555 ) * (e - 10.0 );
hum = temp + h;
}
else if (temp == 0.0 )
{
e = 6.11 * exp( 5417.7530 * (( 1 / 273.16 ) - ( 1 / (dew + 273.16 ))));
h = ( 0.5555 ) * (e - 10.0 );
temp = hum - h;
}
else if (dew == 0.0 )
{
h = hum - temp;
e = h / ( 0.5555 ) + 10.0 ;
dew = 1.0 / (( 1.0 / 273.16 ) - log(e / 6.11 ) / 5417.7530 ) - 273.16 ;
}
printf( " T %.1f D %.1f H %.1f\n " ,temp,dew,hum);
}
return 0 ;
}
#include < math.h >
#include < algorithm >
using namespace std;
int main()
{
char ch1,ch2;
double temp,dew,hum,h,e;
while (cin >> ch1)
{
temp = dew = hum = h = e = 0.0 ;
if (ch1 == ' E ' )
break ;
if (ch1 == ' T ' )
cin >> temp;
else if (ch1 == ' D ' )
cin >> dew;
else if (ch1 == ' H ' )
cin >> hum;
cin >> ch2;
if (ch2 == ' T ' )
cin >> temp;
else if (ch2 == ' D ' )
cin >> dew;
else if (ch2 == ' H ' )
cin >> hum;
if (hum == 0.0 )
{
e = 6.11 * exp( 5417.7530 * (( 1 / 273.16 ) - ( 1 / (dew + 273.16 ))));
h = ( 0.5555 ) * (e - 10.0 );
hum = temp + h;
}
else if (temp == 0.0 )
{
e = 6.11 * exp( 5417.7530 * (( 1 / 273.16 ) - ( 1 / (dew + 273.16 ))));
h = ( 0.5555 ) * (e - 10.0 );
temp = hum - h;
}
else if (dew == 0.0 )
{
h = hum - temp;
e = h / ( 0.5555 ) + 10.0 ;
dew = 1.0 / (( 1.0 / 273.16 ) - log(e / 6.11 ) / 5417.7530 ) - 273.16 ;
}
printf( " T %.1f D %.1f H %.1f\n " ,temp,dew,hum);
}
return 0 ;
}