zoukankan      html  css  js  c++  java
  • poj3299

    2017-08-31 19:08:25

    writer:pprp

    水题:

    没有技术含量hhh

    但是,还是花了很长时间,以后水题也是很有必要练习的

    /*
    @theme:poj 3299
    @writer:pprp
    @declare:刷poj上的题,水题要提高速度,还有理解题意的能力
    @date:2017/8/31
    */
    
    #include <iostream>
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    
    using namespace std;
    
    const double e = 2.718281828;
    const double tmp = 273.16;
    const double tmp2 = 5417.7530;
    const double tmp3 = 0.5555;
    
    //求humidex
    //test:ok
    double fun1(double t, double d)
    {
    
        double e = 6.11 * exp(tmp2*((1/tmp) - (1/(d+tmp))));
        double h = tmp3 * (e - 10.0);
        return t + h;
    }
    //求temperature
    //test:
    double fun2(double h, double d)
    {
        double e = 6.11 * exp(tmp2*((1/tmp) - (1/(d+tmp))));
        double h2 = tmp3 * (e - 10.0);
        return h - h2;
    }
    //求dew point
    //test:
    double fun3(double h, double t)
    {
        double h2 = h - t;
        double e = h2/tmp3 + 10.0;
        return 1.0/(1.0/tmp -((log(e)-log(6.11))/tmp2)) - tmp;
    }
    /*
    int main()
    {
        double t , d;
        cin >> t >> d;
        printf("%.1f",fun1(t,d));
    
        return 0;
    }
    */
    
    int main()
    {
    
        //freopen("in.txt","r",stdin);
        char A, B;
        double a = 0, b = 0;
        char buff[100];
        while(gets(buff) && strcmp(buff,"E") != 0)
        {
            sscanf(buff,"%c %lf %c %lf",&A, &a, &B, &b);
    //        cout << A << endl;
    //        cout << a << endl;
    //        cout << B << endl;
    //        cout << b << endl;
            if(A == 'T')
            {
                if(B == 'D')
                {
    //                cout << "tag" << endl;
                    printf("T %.1f D %.1f H %.1f
    ",a,b,fun1(a,b));
                }
                else if(B == 'H')
                {
                    printf("T %.1f D %.1f H %.1f
    ",a,fun3(b,a),b);
                }
    
            }
            else if(A == 'D')
            {
                if(B == 'H')
                {
                    printf("T %.1f D %.1f H %.1f
    ",fun2(b,a),a,b);
                }
                else if(B == 'T')
                {
                    printf("T %.1f D %.1f H %.1f
    ",b,a,fun1(b,a));
                }
    
            }
            else if(A == 'H')
            {
                if(B == 'T')
                {
                    printf("T %.1f D %.1f H %.1f
    ",b,fun3(a,b),a);
                }
                else if(B == 'D')
                {
                    printf("T %.1f D %.1f H %.1f
    ",fun2(a,b),b,a);
                }
            }
    
        }
    
        return 0;
    }

    注意:double型的要用lf否则就会出错

  • 相关阅读:
    第10组 Alpha冲刺 (4/6)(组长)
    Android菜鸟成长记10 ListVew
    Android菜鸟成长记3activity类
    Android菜鸟成长记2内部类
    Android菜鸟成长记7 Android的五大布局
    Android菜鸟成长记4button点击事件
    Android菜鸟成长记8 布局实践(微信界面的编写)
    Android菜鸟成长记9 selector的用法
    Android菜鸟成长记6 网络连接的检查
    Android菜鸟成长记5ADB和sqllite
  • 原文地址:https://www.cnblogs.com/pprp/p/7460032.html
Copyright © 2011-2022 走看看