poj水题ID3299

不贴题目了,描述的很复杂,其实这个题主要是考察简单的逻辑设计问题吧,看了其他人的答案,有的地方没看懂,还是用麻烦的if else解决的:

#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;
int main()
{
    char a;
    double t,d,h;
    while(cin>>a&&a!='E')
    {
       if(a=='T')
       {
           cin>>t>>a;  
           if(a=='D')  
           {cin>>d;
           h=t+0.5555*(6.11*exp(5417.7530*(1/273.16-1/(d+273.16)))-10); }
           else 
           {
                cin>>h;
                d= 1/((1/273.16)-((log((((h-t)/0.5555)+10.0)/6.11))/5417.7530))-273.16; 
                }
       }
       else if(a=='D')
       {
            cin>>d>>a;
            if(a=='T')
            {cin>>t;
             h=t+0.5555*(6.11*exp(5417.7530*(1/273.16-1/(d+273.16)))-10); 
             }
            else
            {
                cin>>h;
                t=h-0.5555*(6.11*exp(5417.7530*(1/273.16-1/(d+273.16)))-10); 
                }
       }
       else
       {
           cin>>h>>a;
           if(a=='D')
           {
               cin>>d;
               t=h-0.5555*(6.11*exp(5417.7530*(1/273.16-1/(d+273.16)))-10);       
                     }
           else 
           {
                cin>>t;
                d= 1/((1/273.16)-((log((((h-t)/0.5555)+10.0)/6.11))/5417.7530))-273.16;
                }
       }
       cout.setf(ios::fixed);
       cout<<setprecision(1)<<"T "<<t<<" "<<"D "<<d<<" "<<"H "<<h<<endl;
      
     
}
     
}
    
       

  成功AC了。

原文地址:https://www.cnblogs.com/lx09110718/p/poj3299.html