POJ 3299

#include<iostream>
#include<cmath>
#define exp 2.718281828
using namespace std;

float geth(float t,float d){
	float h,e;
	e=6.11*pow(exp,5417.7530*((1/273.16)-(1/(d+273.16))));
	h=0.5555*(e-10);
	return h+t;
}
float gett(float hu,float d){
	float e,h;
	e=6.11*pow(exp,5417.7530*((1/273.16)-(1/(d+273.16))));
	h=0.5555*(e-10);
	return hu-h;
}
float getd(float t,float hu){
	float d,e,h;
	h=hu-t;
	e=h/0.5555+10;
	d=1/(1/273.16-log(e/6.11)/5417.7530)-273.16;
	return d;
}
void assightdh(char c,float &t,float &d,float &h){
	getchar();
	switch (c){
		case 'T':cin>>t;break;
		case 'D':cin>>d;break;
		case 'H':cin>>h;break;
	}
		
}
void cal(float &t,float &d,float &h){
	if(t==101) t=gett(h,d);
	else if(d==101) d=getd(t,h);
	else h=geth(t,d);
}

int main(){
	char a,b;
	float t,d,h;
	while(cin>>a,a!='E'){
		t=d=h=101;
		assightdh(a,t,d,h);
		cin>>b;
		assightdh(b,t,d,h);
		cal(t,d,h);
		printf("T %.1f D %.1f H %.1f\n",t,d,h);
	}
	
	return 0;
}

猜你喜欢

转载自blog.csdn.net/chailyn_trista/article/details/80967100
POJ
今日推荐