poj 3299

这题纯水,但要注意格式化输出读入的细节和考虑问题要全面。原题有原数的用原数。

#include <iostream>
#include <cmath>
#include <stdio.h>


using namespace std;


const double e = 2.718281828;


double td2h(double t,double d)
{
    return t + (0.5555) * (6.11 * pow(e,5417.7530 * ((1/273.16) - (1/(d + 273.16)))) - 10.0);
}


double dh2t(double d,double h)
{
    return h - (0.5555) * (6.11 * pow(e,5417.7530 * ((1/273.16) - (1/(d + 273.16)))) - 10.0);
}


double th2d(double t,double h)
{
    return 273.16 / (1 - 273.16 * log((((h - t) / 0.5555 + 10.0) / 6.11)) /5417.7530) - 273.16;
}


int main()
{
    char c1,c2;
    double p1,p2;
    while(scanf("%c",&c1) && c1 != 'E')
    {
        scanf("%lf %c %lf",&p1,&c2,&p2);
        if(c1 == 'T' && c2 == 'D')
            printf("T %.1lf D %.1lf H %.1lf\n",p1,p2,td2h(p1,p2));
        else if(c2 == 'T' && c1 == 'D')
            printf("T %.1lf D %.1lf H %.1lf\n",p2,p1,td2h(p2,p1));
        else if(c1 == 'D' && c2 == 'H')
            printf("T %.1lf D %.1lf H %.1lf\n",dh2t(p1,p2),p1,p2);
        else if(c2 == 'D' && c1 == 'H')
            printf("T %.1lf D %.1lf H %.1lf\n",dh2t(p2,p1),p2,p1);
        else if(c1 == 'T' && c2 == 'H')
            printf("T %.1lf D %.1lf H %.1lf\n",p1,th2d(p1,p2),p2);
        else if(c2 == 'T' && c1 == 'H')
            printf("T %.1lf D %.1lf H %.1lf\n",p2,th2d(p2,p1),p1);
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值