poj 3299 Humidex(模拟)

题意:三个量,三个公式,知二求一;

思路:求每个量时一口气求出;

#include<cstdio>

#include<cstring>

#include<algorithm>

#include<cmath>

using namespace std;

int t,n,m;

double tem,dew,hum;

char str1[3],str2[3];

int main()

{

    int i,j,k,flag1,flag2,flag3;

    while(scanf("%s",str1)!=EOF)

    {

        if(str1[0]=='E') break;

        flag1=0,flag2=0,flag3=0;

        tem=dew=hum=200;

        if(str1[0]=='T') flag1=1,scanf("%lf",&tem);

        else if(str1[0]=='D') flag2=1,scanf("%lf",&dew);

        else flag3=1,scanf("%lf",&hum);

        scanf("%s",str2);

        if(str2[0]=='T') flag1=1,scanf("%lf",&tem);

        else if(str2[0]=='D') flag2=1,scanf("%lf",&dew);

        else flag3=1,scanf("%lf",&hum);

        if(flag2&&flag1)

             hum=tem+0.5555*(6.11*exp(5417.7530*(1/273.16-1/(dew+273.16)))-10);

        else if(flag2&&flag3)

             tem=hum-0.5555*(6.11*exp(5417.7530*(1/273.16-1/(dew+273.16)))-10);

        else 

            dew=1/((1/273.16)-((log((((hum-tem)/0.5555)+10.0)/6.11))/5417.7530))-273.16;

        printf("T %.1f D %.1f H %.1f\n",tem,dew,hum);

    }

    return 0;

}

 

你可能感兴趣的:(ide)