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否则就会出错

  • 相关阅读:
    MATLAB使用fft求取给定音频信号的频率
    python实现抓取必应图片设置桌面
    [原创]Nexus5 移植OneStep
    [原创]Nexus5 内核编译烧录过程记录
    repo版本切换
    pthread
    《Android进阶》Sqlite的使用
    【转】iOS夯实:ARC时代的内存管理
    【转】如何使App从后台返回前台时,显示指定界面
    【转】自定义UITableViewCell(registerNib: 与 registerClass: 的区别)
  • 原文地址:https://www.cnblogs.com/pprp/p/7460032.html
Copyright © 2011-2022 走看看