POJ 3299

it2022-05-08  10

//题目类型:水题(数论)//解题思路:看清题意,直接推导公式即可 #include <iostream>#include <stdio.h>//#include <conio.h>#include <math.h>using namespace std;double temper,humidex,dew;void solvedew(){    dew = 1/(1/273.16-log((humidex-temper+5.555)/(0.5555*6.11))/5417.7530)-273.16;}void solvetemper(){    temper = humidex-(0.5555)*(6.11*exp(5417.7530*((1/273.16) - (1/(dew+273.16)))) - 10.0);}void solvehumidex(){    humidex = temper + (0.5555)*(6.11*exp(5417.7530*((1/273.16) - (1/(dew+273.16)))) - 10.0);      }int main(){    //freopen("1.txt","r",stdin);    bool botemper,bohumidex,bodew;    char ch[5];    while(1)    {        botemper = false;        bohumidex = false;        bodew = false;        scanf("%s",ch);   //尽量采用字符串读字符         if(ch[0]=='E') break;        else if(ch[0]=='T')         {             scanf("%lf",&temper);        //G++中双精度浮点数使用scanf读取时依然采用%lf             botemper = true;         }        else if(ch[0]=='D')        {             scanf("%lf",&dew);                     bodew = true;        }        else if(ch[0]=='H')        {             scanf("%lf",&humidex);             bohumidex = true;        }        scanf("%s",ch);        if(ch[0]=='T')         {             scanf("%lf",&temper);              botemper = true;         }        else if(ch[0]=='D')        {             scanf("%lf",&dew);             bodew = true;        }        else if(ch[0]=='H')        {             scanf("%lf",&humidex);             bohumidex = true;        }        if(bodew && botemper) solvehumidex();        else if(bodew && bohumidex) solvetemper();        else if(botemper && bohumidex) solvedew();        //printf("T %.1lf D %.1lf H %.1lf\n",temper,dew,humidex);        printf("T %.1f D %.1f H %.1f\n",temper,dew,humidex);     //特别注意G++中不支持%lf     }    //getch();    return 0;}

转载于:https://www.cnblogs.com/north_dragon/archive/2010/09/29/1838304.html

相关资源:数据结构—成绩单生成器

最新回复(0)