poj3299

#include 
#include 
#include 
using namespace std;

double HH(double TT,double DD)
{
    double h,e;
    e=6.11*exp(5417.7530*((1/273.16)-(1/(DD+273.16))));
    h=0.5555*(e-10.0);
    return TT+h;
}

double DD(double TT,double HH)
{
    double h,e,p;
    h=HH-TT;
    e=h/0.5555+10.0;
    p=log(e/6.11);
    p=p/5417.7530;
    p=(1/273.16)-p;
    return 1/p-273.16;


}

double TT(double DD,double HH)
{
    double h,e;
    e=6.11*exp(5417.7530*((1/273.16)-(1/(DD+273.16))));
    h=0.5555*(e-10.0);
    return HH-h;

}
 
int main()
{   double T,D,H;
    char type1,type2;
    cin>>type1;
    while (type1!='E')
    {
        if (type1=='T') cin>>T;
        if (type1=='D') cin>>D;
        if (type1=='H') cin>>H;
        cin>>type2;
        if (type2=='T') cin>>T;
        if (type2=='D') cin>>D;
        if (type2=='H') cin>>H;
        if ((type1!='H')&&(type2!='H')) H=HH(T,D);
        if ((type1!='D')&&(type2!='D')) D=DD(T,H);
        if ((type1!='T')&&(type2!='T')) T=TT(D,H);
        cout<<"T ";
        printf("%.1lf",T);
        cout<<" D ";
        printf("%.1lf",D);
        cout<<" H ";
        printf("%.1lf\n",H);
        cin>>type1;
    }
    return 0;
}
就是有H(humidex),D(dewpoint),T(humidex)三个值;输入其中的两个值,然后通过humidex = temperature + hh = (0.5555)× (e - 10.0)e = 6.11 × exp [5417.7530 × ((1/273.16) - (1/(dewpoint+273.16)))]三个公式解出剩下的一个值,然后把三个都输出来。

你可能感兴趣的:(模拟)