2017-08-31 19:08:25
writer:pprp
水题:
没有技术含量hhh
但是,还是花了很长时间,以后水题也是很有必要练习的
/*
@theme:poj 3299
@writer:pprp
@declare:刷poj上的题,水题要提高速度,还有理解题意的能力
@date:2017/8/31
*/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
const double e = 2.718281828;
const double tmp = 273.16;
const double tmp2 = 5417.7530;
const double tmp3 = 0.5555;
//求humidex
//test:ok
double fun1(double t, double d)
{
double e = 6.11 * exp(tmp2*((1/tmp) - (1/(d+tmp))));
double h = tmp3 * (e - 10.0);
return t + h;
}
//求temperature
//test:
double fun2(double h, double d)
{
double e = 6.11 * exp(tmp2*((1/tmp) - (1/(d+tmp))));
double h2 = tmp3 * (e - 10.0);
return h - h2;
}
//求dew point
//test:
double fun3(double h, double t)
{
double h2 = h - t;
double e = h2/tmp3 + 10.0;
return 1.0/(1.0/tmp -((log(e)-log(6.11))/tmp2)) - tmp;
}
/*
int main()
{
double t , d;
cin >> t >> d;
printf("%.1f",fun1(t,d));
return 0;
}
*/
int main()
{
//freopen("in.txt","r",stdin);
char A, B;
double a = 0, b = 0;
char buff[100];
while(gets(buff) && strcmp(buff,"E") != 0)
{
sscanf(buff,"%c %lf %c %lf",&A, &a, &B, &b);
// cout << A << endl;
// cout << a << endl;
// cout << B << endl;
// cout << b << endl;
if(A == 'T')
{
if(B == 'D')
{
// cout << "tag" << endl;
printf("T %.1f D %.1f H %.1f\n",a,b,fun1(a,b));
}
else if(B == 'H')
{
printf("T %.1f D %.1f H %.1f\n",a,fun3(b,a),b);
}
}
else if(A == 'D')
{
if(B == 'H')
{
printf("T %.1f D %.1f H %.1f\n",fun2(b,a),a,b);
}
else if(B == 'T')
{
printf("T %.1f D %.1f H %.1f\n",b,a,fun1(b,a));
}
}
else if(A == 'H')
{
if(B == 'T')
{
printf("T %.1f D %.1f H %.1f\n",b,fun3(a,b),a);
}
else if(B == 'D')
{
printf("T %.1f D %.1f H %.1f\n",fun2(a,b),b,a);
}
}
}
return 0;
}
注意:double型的要用lf否则就会出错