POJ----- 3299 Humidex

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/MrWilliamVs/article/details/47658187
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

double T_D(double T , double D)
{
		double H, h, e, tem;
		tem = 5417.7530 * ((1/273.16) - (1/(D + 273.16)));
		e = 6.11 * pow(2.718281828, tem);
		h = 0.5555 * (e - 10.0);
		H = T + h;
		return H;
}

double T_H(double T, double H)
{
	double D, h, e, temp;
	h = H - T;
	e = h/0.5555 + 10.0;
	temp = log(e/6.11) / log(2.718281828);
	D = 1/(1/273.16 - temp/5417.7530) - 273.16;
	return D;
}

double D_H(double D, double H)
{
	double T, e, h, temp;
	temp = 5417.7530 * ((1/273.16) - (1/(D + 273.16)));
	e = 6.11*pow(e,temp);
	h = 0.5555*(e - 10.0);
	T = H - h;
	return T;
}

int main()
{
	char A, B;
	double a, b;
	while(cin>>A>>a>>B>>b)
	{
		if(A == 'E')
			break;
		double c;
       if(A=='T'&&B=='D')
	   {
		   c = T_D(a,b);
		cout<<'T'<<' '<<fixed<<setprecision(1)<<a<<' '<<'D'<<' '<<b<<' '<<'H'<<' '<<c<<endl;
	   }
	   else if(A=='D'&&B=='T')
	   {
		     c = T_D(b,a);
		cout<<'T'<<' '<<fixed<<setprecision(1)<<b<<' '<<'D'<<' '<<a<<' '<<'H'<<' '<<c<<endl;
	   }
	    else if(A=='T'&&B=='H')
	   {
		     c = T_H(a,b);
		cout<<'T'<<' '<<fixed<<setprecision(1)<<a<<' '<<'D'<<' '<<c<<' '<<'H'<<' '<<b<<endl;
	   }
	    else if(A=='H'&&B=='T')
	   {
		     c = T_H(b,a);
		cout<<'T'<<' '<<fixed<<setprecision(1)<<b<<' '<<'D'<<' '<<c<<' '<<'H'<<' '<<a<<endl;
	   }
		 else if(A=='D'&&B=='H')
	   {
		     c = D_H(a,b);
		cout<<'T'<<' '<<fixed<<setprecision(1)<<c<<' '<<'D'<<' '<<a<<' '<<'H'<<' '<<b<<endl;
	   }
		 else if(A=='H'&&B=='D')
	   {
		     c = (b,a);
		cout<<'T'<<' '<<fixed<<setprecision(1)<<c<<' '<<'D'<<' '<<b<<' '<<'H'<<' '<<a<<endl;
	   }
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/MrWilliamVs/article/details/47658187
POJ
今日推荐