Humidexpoj3299

来源:互联网 发布:java实现学生管理系统 编辑:程序博客网 时间:2024/05/23 19:18

模拟。
注意输入为很多种情况,TD,TH,DH

#include<cstdio>#include<cmath>#include<algorithm>#include<cstring>using namespace std;char s1[100],s2[100];double t,d,h;double a1,a2;double E=2.718281828;int vis[300];void fun(char c,double x){    if(c=='T')    {        vis[c]=1;        t=x;    }    else if(c=='D')    {        vis[c]=1;        d=x;    }    else    {        vis[c]=1;        h=x;    }}int main(){    while(scanf("%s",s1)!=EOF)    {        memset(vis,0,sizeof vis);        if(s1[0]=='E')            break;        scanf("%lf",&a1);        scanf("%s%lf",s2,&a2);        fun(s1[0],a1);        fun(s2[0],a2);        if(!vis['H'])        {            double e=6.11*exp(5417.7530 * ((1.0/273.16) - (1.0/(d+273.16))));            h=  (0.5555)* (e - 10.0)+t;        }        if(!vis['T'])        {              double e=6.11*pow(E,(5417.7530 * ((1.0/273.16) - (1.0/(d+273.16)))));              t=h-(0.5555)* (e - 10.0);        }        if(!vis['D'])        {            double e=(h-t)/(0.5555)+ 10.0;            d=1/((1/273.16)-log(e/6.11)/5417.7530 )-273.16;        }        printf("T %.1f D %.1f H %.1f\n",t,d,h);    }    return 0;}
0 0