题目链接:http://poj.org/problem?id=3299
#include <iostream> #include <iomanip> using namespace std; double exp(double x){ double ans=1; double td=1; for(int i=1;i<120;i++){ td=td*x/i; ans+=td; } return ans; } const double ine= 2.718281828 ; double ln(double x){ double ans=0; while(x<-1||x>1){ ans++; x=(x+1)/ine-1; } double td=-1; for(int i=1;i<120;i++){ td*=-x; ans+=td/(double)i; } return ans; } double t,d,h,temp; int flag; int main(){ ios::sync_with_stdio(false); char st[9]; while(cin>>st){ flag=0; if(st[0]=='E'){ break; } cin>>temp; if(st[0]=='T'){ flag+=1; t=temp; } else if(st[0]=='D'){ flag+=2; d=temp; } else if(st[0]=='H'){ flag+=3; h=temp; } cin>>st; cin>>temp; if(st[0]=='T'){ flag+=1; t=temp; } else if(st[0]=='D'){ flag+=2; d=temp; } else if(st[0]=='H'){ flag+=3; h=temp; } if(flag==3) h=t-5.555+0.555*6.11*exp(5417.7530* ((1/273.16) - (1/(d+273.16)))); else if(flag==4) { double e=((h-t)/0.5555)+10.0; double td=ln((e/6.11)-1); d=1.0/((1.0/273.16)-td/5417.7530)-273.16; } else t= h+ 5.555- 0.555*6.11*exp(5417.7530* ((1/273.16) - (1/(d+273.16)))); cout<<"T "<<setiosflags(ios::fixed)<<setprecision(1)<<t<<" D "<<d<<" H "<<h<<" "; } return 0; }