Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d
& %I64u

Description

Adapted from Wikipedia, the free encyclopedia

The humidex is a measurement used by Canadian meteorologists to reflect the combined effect of heat and humidity. It differs from the heat index used in the United States in using dew point rather than relative humidity.

When the temperature is 30°C (86°F) and the dew point is 15°C (59°F), the humidex is 34 (note that humidex is a dimensionless number, but that the number indicates an approximate temperature in C). If the temperature remains 30°C and the dew point rises
to 25°C (77°F), the humidex rises to 42.3.

The humidex tends to be higher than the U.S. heat index at equal temperature and relative humidity.

The current formula for determining the humidex was developed by J.M. Masterton and F.A. Richardson of Canada's Atmospheric Environment Service in 1979.

According to the Meteorological Service of Canada, a humidex of at least 40 causes "great discomfort" and above 45 is "dangerous." When the humidex hits 54, heat stroke is imminent.

The record humidex in Canada occurred on June 20, 1953, when Windsor, Ontario hit 52.1. (The residents of Windsor would not have known this at the time, since the humidex had yet to be invented.) More recently, the humidex reached 50 on July 14, 1995 in
both Windsor and Toronto.

The humidex formula is as follows:

humidex = temperature + h
h = (0.5555)× (e - 10.0)
e = 6.11 × exp [5417.7530 × ((1/273.16) - (1/(dewpoint+273.16)))]

where exp(x) is 2.718281828 raised to the exponent x.

While humidex is just a number, radio announcers often announce it as if it were the temperature, e.g. "It's 47 degrees out there ... [pause] .. with the humidex,". Sometimes weather reports give the temperature and dewpoint, or the temperature and humidex,
but rarely do they report all three measurements. Write a program that, given any two of the measurements, will calculate the third.

You may assume that for all inputs, the temperature, dewpoint, and humidex are all between -100°C and 100°C.

Input

Input will consist of a number of lines. Each line except the last will consist of four items separated by spaces: a letter, a number, a second letter, and a second number. Each letter specifies the meaning of the number that follows it, and will be either
T, indicating temperature, D, indicating dewpoint, or H, indicating humidex. The last line of input will consist of the single letter E.

Output

For each line of input except the last, produce one line of output. Each line of output should have the form:

T number D number H number

where the three numbers are replaced with the temperature, dewpoint, and humidex. Each value should be expressed rounded to the nearest tenth of a degree, with exactly one digit after the decimal point. All temperatures are in degrees celsius.

Sample Input

T 30 D 15
T 30.0 D 25.0
E

Sample Output

T 30.0 D 15.0 H 34.0
T 30.0 D 25.0 H 42.3
#include <iostream>
#include<cmath>
#include<iomanip>
using namespace std;
char a,b;
double A,B,temp,hum,dew;
double srzs(double tt,double dd)
{ double e = 6.11 * exp (5417.7530 * ((1/273.16) - (1/(dd+273.16))));
double h = (0.5555)*(e - 10.0);
return tt + h;
}
double wd()
{
double e = 6.11 * exp (5417.7530 * ((1/273.16) - (1/(dew+273.16))));
double h = (0.5555)*(e - 10.0);
return hum - h;
}
double ld()
{
double x = 0;
double delta=100;
for (delta=100;delta>.00001;delta *=.5) {
if (srzs(temp,x)>hum) x -= delta;
else x += delta;
}
return x;
}
int main()
{
while (cin>>a&&a!='E')
{
dew=hum=temp=-99999;
cin>>A>>b>>B;
switch(a)
{case 'T':temp = A; break;
case 'D':dew = A; break;
case 'H':hum = A; break;
}
switch(b)
{case 'T':temp=B;break;
case 'D':dew=B;break;
case 'H':hum=B;break;}
if(hum==-99999)
hum =srzs(temp,dew);
if(dew==-99999)
dew=ld();
if(temp==-99999)
temp=wd();
cout<<fixed<<setprecision(1)<<"T "<<temp<<" D "<<dew<<" H "<<hum<<endl;
}
return 0;
}

最新文章

  1. MetInfo 5.1 自动化getshell工具
  2. Linux Shell 重定向与管道【转帖】
  3. maven引入本地jar
  4. JAVA https证书相关
  5. VC++NMAKE
  6. java 代码分析工具——JDepend
  7. Sqli-labs less 65
  8. Unity 教程和源码
  9. oracle的控制语句if和循环语句loop while for
  10. 第4章 类型基础 -- 4.1 所有类型都从System.Object派生
  11. DOM事件一览表
  12. PHP学习笔记-1
  13. Java Map List 的使用
  14. bootstrap学习笔记之基础导航条 http://www.imooc.com/code/3111
  15. QT的安装及环境配置
  16. 【原创】XAF Winfrom 支持4K分辨率
  17. Chapter 5 Blood Type——16
  18. 用反射的形式将一个对象属性值赋值给另一个对象,省略点get/set方法的冗余代码
  19. JavaScript数组删除指定元素
  20. linux --- 6. 项目部署

热门文章

  1. Matlab从入门到精通 Chapter5 数据可视化--
  2. Vue this.$router.push、replace、go的区别
  3. NodeJS学习笔记 (5)网络服务-http-req(ok)
  4. linux 删除命令注意事项(大神勿看)
  5. [Debug]SpaceVim中neomake报错 Error while trying to load a compilation database
  6. VUEJS开发规范
  7. caioj 1153 扩展欧几里德算法(解不定方程)
  8. 平凡主丛上的Yang-Mills理论
  9. mac和iphone处理视频
  10. hadoop-08-关闭THP服务