zoukankan      html  css  js  c++  java
  • poj3299 Humidex

    The humidex formula is as follows:

    humidex = temperature + h
    h = (0.5555)× (e - 10.0)
    e = 6.11 × exp [5417.7530 × ((1/273.16) - (1/(dewpoint+273.16)))]
    where exp(x) is 2.718281828 raised to the exponent x.

    While humidex is just a number, radio announcers often announce it as if it were the temperature, e.g. "It's 47 degrees out there ... [pause] .. with the humidex,". Sometimes weather reports give the temperature and dewpoint, or the temperature and humidex, but rarely do they report all three measurements. Write a program that, given any two of the measurements, will calculate the third.

    You may assume that for all inputs, the temperature, dewpoint, and humidex are all between -100°C and 100°C.

    Input

    Input will consist of a number of lines. Each line except the last will consist of four items separated by spaces: a letter, a number, a second letter, and a second number. Each letter specifies the meaning of the number that follows it, and will be either T, indicating temperature, D, indicating dewpoint, or H, indicating humidex. The last line of input will consist of the single letter E.

    Output

    For each line of input except the last, produce one line of output. Each line of output should have the form:

     T number D number H number

    where the three numbers are replaced with the temperature, dewpoint, and humidex. Each value should be expressed rounded to the nearest tenth of a degree, with exactly one digit after the decimal point. All temperatures are in degrees celsius.

    Sample Input

    T 30 D 15
    T 30.0 D 25.0
    E

    Sample Output

    T 30.0 D 15.0 H 34.0
    T 30.0 D 25.0 H 42.3
    #include <iostream>
    #include <cmath>
    using namespace std;
     
    const double e = 2.718281828;
     
    double fun1(double h, double d)//求T
    {
     return h - (0.5555 * ((6.11 * pow(e, 5417.7530*(1/273.16-1/(d+273.16)))) - 10.0));
    }
     
    double fun2(double t, double d)//求H
    {
        return t + (0.5555 * ((6.11*pow(e,5417.7530*(1/273.16-1/(d+273.16)))) - 10.0));
    }
     
    double fun3(double t, double h)//求D
    {
        return 1/(1/273.16 - log(((h-t)/0.5555+10.0)/6.11)/5417.7530) - 273.16;
    }
     
    int main()
    {
        char a1,a2;
        double t1,t2;
        while(scanf("%c", &a1) && a1 != 'E')
        {
            scanf("%lf %c %lf", &t1, &a2, &t2);
            //printf("%c %lf %c %lf
    ", a1, t1, a2, t2);
            //输出
            //数据前后顺序,如T 30 D 15和D 15 T 30答案应该一样
            if(a1=='D'&&a2=='H')
                printf("T %.1f D %.1f H %.1f
    ",fun1(t2,t1),t1,t2);
            else if(a1=='H'&&a2=='D')
                printf("T %.1f D %.1f H %.1f
    ",fun1(t1,t2),t2,t1);
            else if(a1=='T'&&a2=='D')
                printf("T %.1f D %.1f H %.1f
    ",t1,t2,fun2(t1,t2));
            else if(a1=='D'&&a2=='T')
                printf("T %.1f D %.1f H %.1f
    ",t2,t1,fun2(t2,t1));
            else if(a1=='T'&&a2=='H')
                printf("T %.1f D %.1f H %.1f
    ",t1,fun3(t1,t2),t2);
            else if(a1=='H'&&a2=='T')
                printf("T %.1f D %.1f H %.1f
    ",t2,fun3(t2,t1),t1);   
        }
        return 0;
    }
  • 相关阅读:
    [补]2019HDU杭电多校第一场A
    [补]2019nowcoder牛客第三场F(暂且)
    [补]2019nowcoder牛客第一场E、I
    [学]从零(多项式基础与FFT)开始BM学习笔记
    [补]2019nowcoder牛客第二场E、H(upd0730)
    从一个简单的例子对win 服务程序进行讲解
    HTTP协议学习记录及总结
    Windows身份验证与forms身份验证的结合
    关于Sql server 的 几道面试题
    PlaceHolder控件的使用
  • 原文地址:https://www.cnblogs.com/lingc/p/3410397.html
Copyright © 2011-2022 走看看