poj 3299

来源:互联网 发布:淘宝付款收不到验证码 编辑:程序博客网 时间:2024/05/18 12:04

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

#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;}


原创粉丝点击