poj3299 - Humidex

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\n",a,b,fun1(a,b));
            }
            else if(B == 'H')
            {
                printf("T %.1f D %.1f H %.1f\n",a,fun3(b,a),b);
            }

        }
        else if(A == 'D')
        {
            if(B == 'H')
            {
                printf("T %.1f D %.1f H %.1f\n",fun2(b,a),a,b);
            }
            else if(B == 'T')
            {
                printf("T %.1f D %.1f H %.1f\n",b,a,fun1(b,a));
            }

        }
        else if(A == 'H')
        {
            if(B == 'T')
            {
                printf("T %.1f D %.1f H %.1f\n",b,fun3(a,b),a);
            }
            else if(B == 'D')
            {
                printf("T %.1f D %.1f H %.1f\n",fun2(a,b),b,a);
            }
        }

    }

    return 0;
}

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

转载于:https://www.cnblogs.com/pprp/p/7460032.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值