poj 3299 humidex

来源:互联网 发布:mac air与mac pro区别 编辑:程序博客网 时间:2024/05/16 07:03
#include  //H=T+h(D)
#include  
#include  
using namespace std;  
  
int main()  
{  
    double one, two; 
    char first, second; 
    cout <<setprecision ( 1 )  << fixed; 
  
    while ( cin >>first && first != 'E' )  
   
       cin >> one >> second >> two; 
       if ( first == 'T' || second == 'T' ) 
       {  
           if ( first!= 'T' )  
          
              swap(first,second); 
              swap(one,two); 
          
           if (second == 'D' )  //T&&D
          
              double h = ( 0.5555 ) * ( 6.11 * exp( 5417.7530 * ( 1 / 273.16 - 1 / ( two + 273.16 ) ) ) - 10.0 ); 
              cout << "T " <<one << " D " << two << " H " << one + h<< endl;  
          
           else               //T&&H
          
              double d = -273.16 - 1 / (log( ((two - one )/ 0.5555 + 10.0) / 6.11 ) / 5417.7530 - 1 / 273.16); 
              cout << "T " <<one << " D " << d << " H " << two <<endl;  
          
       }  
       else  
       {  
           if ( first!= 'H' )  
          
              swap(first,second); 
              swap(one,two);   //H&&D
           
           double t =one - ( 0.5555 ) * (  6.11 * exp( 5417.7530 * ( 1/ 273.16 -  1 / ( two + 273.16 ) ) ) - 10.0 ); 
           cout<< "T " << t << " D " << two << " H "<< one << endl;  
       }  
   
    return 0; 
}