POJ 3299

来源:互联网 发布:淘宝童装模特拍摄价格 编辑:程序博客网 时间:2024/04/29 04:50
#include <iostream>#include<cstdio>#include<cmath>using namespace std;const char *s="TDH";double tem,dew,ham;void TD()    {        double e=6.11*exp(5417.7530*((1.0/273.16)-(1.0/(dew+273.16))));        double h=0.5555*(e-10.0);        ham=tem+h;    }    void TH()    {        double h=ham-tem;        double e=(h/0.5555)+10.0;        double a=e/6.11;        double b=log(a);        double c=b/5417.7530;        double d=(1.0/273.16)-c;        dew=(1.0/d)-273.16;    }    void DH()    {        double e=6.11 * exp (5417.7530 * ((1.0/273.16) - (1.0/(dew+273.16))));        double h=0.5555*(e-10.0);        tem=ham-h;    }    int main()    {        char a,b;        double x,y;        while(cin>>a)        {            if(a=='E') break;            cin>>x>>b>>y;            int k,t;            for(int i=0;i<3;i++)            {                if(a==s[i]) k=i;                if(b==s[i]) t=i;            }            if(k==0&&t==1) {  tem=x; dew=y;  TD();}            else if(k==1&&t==0)  {dew=x; tem=y; TD();}                   else if(k==0&&t==2) { tem=x; ham=y; TH();}                           else if(k==2&&t==0) {ham=x; tem=y; TH();}                                   else if(k==1&&t==2) {dew=x; ham=y; DH();}                                           else  if(k==2&&t==1) { ham=x; dew=y; DH();}            printf("T %.1f D %.1f H %.1f\n",tem,dew,ham);          }        return 0;    }
原创粉丝点击