题目链接:http://poj.org/problem?id=3299
挺扯蛋的一题,本来想刷点水题,结果让这题的题目给虐了...抽空得好好补补英语了。主要是公式的推导
代码:
#include<iostream>
#include<cstdio>
#include<math.h>
using namespace std;
float e = 2.718281828 ;
float fun1(float h, float d){
return h-(0.5555*((6.11*pow(e,5417.7530*(1/273.16-1/(d+273.16))))-10.0)) ;
}
float fun2(float t,float d){
return t+(0.5555*((6.11*pow(e,5417.7530*(1/273.16-1/(d+273.16))))-10.0)) ;
}
float fun3(float t,float h){
return 1/(1/273.16-log(((h-t)/0.5555+10.0)/6.11)/5417.7530)-273.16 ;
}
int main(){
char L[100] ;
char a1, a2 ;
float t1, t2 ;
while(true){
cin >> a1 ;
if(a1=='E')
break ;
cin >> t1 >> a2 >> t2 ;
if(a1=='D'&&a2=='H')
printf("T %.1f D %.1f H %.1f\n",fun1(t2,t1),t1,t2) ;
else if(a1=='H'&&a2=='D')
printf("T %.1f D %.1f H %.1f\n",fun1(t1,t2),t2,t1) ;
else if(a1=='T'&&a2=='D')
printf("T %.1f D %.1f H %.1f\n",t1,t2,fun2(t1,t2)) ;
else if(a1=='D'&&a2=='T')
printf("T %.1f D %.1f H %.1f\n",t2,t1,fun2(t2,t1)) ;
else if(a1=='T'&&a2=='H')
printf("T %.1f D %.1f H %.1f\n",t1,fun3(t1,t2),t2);
else if(a1=='H'&&a2=='T')
printf("T %.1f D %.1f H %.1f\n",t2,fun3(t2,t1),t1) ;
}
}
#include<cstdio>
#include<math.h>
using namespace std;
float e = 2.718281828 ;
float fun1(float h, float d){
return h-(0.5555*((6.11*pow(e,5417.7530*(1/273.16-1/(d+273.16))))-10.0)) ;
}
float fun2(float t,float d){
return t+(0.5555*((6.11*pow(e,5417.7530*(1/273.16-1/(d+273.16))))-10.0)) ;
}
float fun3(float t,float h){
return 1/(1/273.16-log(((h-t)/0.5555+10.0)/6.11)/5417.7530)-273.16 ;
}
int main(){
char L[100] ;
char a1, a2 ;
float t1, t2 ;
while(true){
cin >> a1 ;
if(a1=='E')
break ;
cin >> t1 >> a2 >> t2 ;
if(a1=='D'&&a2=='H')
printf("T %.1f D %.1f H %.1f\n",fun1(t2,t1),t1,t2) ;
else if(a1=='H'&&a2=='D')
printf("T %.1f D %.1f H %.1f\n",fun1(t1,t2),t2,t1) ;
else if(a1=='T'&&a2=='D')
printf("T %.1f D %.1f H %.1f\n",t1,t2,fun2(t1,t2)) ;
else if(a1=='D'&&a2=='T')
printf("T %.1f D %.1f H %.1f\n",t2,t1,fun2(t2,t1)) ;
else if(a1=='T'&&a2=='H')
printf("T %.1f D %.1f H %.1f\n",t1,fun3(t1,t2),t2);
else if(a1=='H'&&a2=='T')
printf("T %.1f D %.1f H %.1f\n",t2,fun3(t2,t1),t1) ;
}
}