#include <iostream> #include <cstdio> #include <cmath> #define MAXN 101 using namespace std; int main() { char c; double t,d,h; while(1) { t = MAXN; d = MAXN; h = MAXN; int cnt = 2; while(cnt--) { scanf("%c",&c); if(c=='E') return 0; else if(c=='T') scanf("%lf",&t); else if(c=='D') scanf("%lf",&d); else if(c=='H') scanf("%lf",&h); getchar(); } if(h==MAXN) h=t+0.5555*(6.11*exp(5417.7530*(1/273.16-1/(d+273.16)))-10); else if(t==MAXN) t=h-0.5555*(6.11*exp(5417.7530*(1/273.16-1/(d+273.16)))-10); else if(d==MAXN) d=1/((1/273.16)-((log((((h-t)/0.5555)+10.0)/6.11))/5417.7530))-273.16; printf("T %.1lf D %.1lf H %.1lf ",t,d,h); } return 0; }
直接推导公式,然后就可以,记得加个getchar,开始输一个结果就直接输出了,果然是getchar没加啊,还有一个比较奇怪的,g++过不了,c++过了。。。