这题一上来给我下了个套,我一开始没看清题意,以为是知道T,D求H,结果不是啊!!直接贡献了一个WA,oh,my god!这题真正的意图是知二求一,任意知道两个量求第三个量,公式直接给了,所以我就不说什么了,代公式就可以。
代码如下
#include<stdio.h>
#include<stdlib.h>#include<math.h>
void td(double t,double d)
{
double p,e,h;
e=6.11*exp(5417.7530 * ((1/273.16) - (1/(d+273.16))));
h=(0.5555)*(e - 10.0)+t;
printf("T %.1lf D %.1lf H %.1lf\n",t,d,h);
}
void th(double t,double h)
{
double e,d;
e=(h-t)/0.5555+10.0;
d=1/(1.0/273.16-log(e/6.11)/5417.7530)-273.16;
printf("T %.1lf D %.1lf H %.1lf\n",t,d,h);
}
void dh(double d,double h)
{
double e,t;
e=6.11*exp(5417.7530 * ((1/273.16) - (1/(d+273.16))));
t=h-(0.5555)*(e - 10.0);
printf("T %.1lf D %.1lf H %.1lf\n",t,d,h);
}
void main()
{
char c,c1;
double t,d;
while(scanf("%c",&c)!=EOF)
{
if(c=='E') break;
scanf("%lf %c %lf",&t,&c1,&d);
if(c=='T'&&c1=='D') td(t,d);
else if(c=='D'&&c1=='T') td(d,t);
else if(c=='D'&&c1=='H') dh(t,d);
else if(c=='H'&&c1=='D') dh(d,t);
else if(c=='T'&&c1=='H') th(t,d);
else th(d,t);
getchar();
}
}