poj-3299-Humidex

传送门
题意:给temperature, dewpoint, humidex之中的两个数,然后求出第三个数,并输出
公式如下
humidex = temperature + h
h = (0.5555)× (e - 10.0)
e = 6.11 × exp [5417.7530 × ((1/273.16) - (1/(dewpoint+273.16)))]
exp(x) 是2.718281828x


先判断输入的是哪两个数,然后根据这两个数计算出另一个数

#include <iostream> 
#include <cstdio>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#define N 10
#define E 2.718281828
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
    freopen("1.txt", "r", stdin);
#endif  
    double t, d, h, t1, t2;
    char c;
    while(cin >> c){
        t = d = h = -1.0;
        if (c == 'E'){
            break;
        }
        switch(c){
            case 'T': cin >> t; break;
            case 'D': cin >> d; break;
            case 'H': cin >> h; break;
        }
        cin >> c;
        switch(c){
            case 'T': cin >> t; break;
            case 'D': cin >> d; break;
            case 'H': cin >> h; break;
        }
        if (h < 0){
            h = t;
            h += 0.5555 * ((6.11 * pow(E, (5417.7530*((1/273.16)-(1.0/(d+273.16)))))) - 10.0);
        }else if (d < 0){
            t1 = log(((h - t)/0.5555 + 10.0)/6.11)/5417.7530;
            t1 = 1/273.16-t1;
            t1 = 1/t1;
            d = t1 - 273.16;
        }else{
            t = h - 0.5555 * ((6.11 * pow(E, (5417.7530*((1/273.16)-(1.0/(d+273.16)))))) - 10.0);
        }
        cout  << fixed << setprecision(1) << "T " << t << " D " << d << " H " << h << endl;
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值