F - Humidex(1.4.2)
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
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;
}
F - Humidex(1.4.2)的更多相关文章
- Mysql_以案例为基准之查询
查询数据操作
- 3299 Humidex
Humidex Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 23219 Accepted: 8264 Descript ...
- 在 C# 里使用 F# 的 option 变量
在使用 C# 与 F# 混合编程的时候(通常是使用 C# 实现 GUI,F#负责数据处理),经常会遇到要判断一个 option 是 None 还是 Some.虽然 Option module 里有 i ...
- 如果你也会C#,那不妨了解下F#(7):面向对象编程之继承、接口和泛型
前言 面向对象三大基本特性:封装.继承.多态.上一篇中介绍了类的定义,下面就了解下F#中继承和多态的使用吧.
- 如果你也会C#,那不妨了解下F#(2):数值运算和流程控制语法
本文链接:http://www.cnblogs.com/hjklin/p/fs-for-cs-dev-2.html 一些废话 一门语言火不火,与语言本身并没太大关系,主要看语言的推广. 推广得好,用的 ...
- 使用F#开发ASP.NET Core应用程序
.NET Core 里的F# 在.NET Core刚发布时,就已经添加了对F#的支持.但因为当时F#组件还不完整,而一些依赖包并没有放在Nuget上,而是社区自己放到MyGet上,所以在使用dotne ...
- 如果你也会C#,那不妨了解下F#(6):面向对象编程之“类”
前言 面向对象的思想已经非常成熟,而使用C#的程序员对面向对象也是非常熟悉,所以我就不对面向对象进行介绍了,在这篇文章中将只会介绍面向对象在F#中的使用. F#是支持面向对象的函数式编程语言,所以你用 ...
- 如果你也会C#,那不妨了解下F#(5):模块、与C#互相调用
F# 项目 在之前的几篇文章介绍的代码都在交互窗口(fsi.exe)里运行,但平常开发的软件程序可能含有大类类型和函数定义,代码不可能都在一个文件里.下面我们来看VS里提供的F#项目模板. F#项目模 ...
- 如果你也会C#,那不妨了解下F#(4):了解函数及常用函数
函数式编程其实就是按照数学上的函数运算思想来实现计算机上的运算.虽然我们不需要深入了解数学函数的知识,但应该清楚函数式编程的基础是来自于数学. 例如数学函数\(f(x) = x^2+x\),并没有指定 ...
随机推荐
- 基本数据类型(dict)
1.定义 dict => {"key":'value',"a":1} 字典是无序的,字典是可变的 字典的键 => 可哈希(不可变),唯一 字典的值 ...
- 转义JavaScript特殊字符
JavaScriptUtils.javaScriptEscape("%admin' or '1=1") //转义JavaScript特殊字符
- [React Native] Dismiss the Keyboard in React Native
In this lesson you will learn how create a re-usable component that gives the user the ability to di ...
- C++ 数字、string 简便互转
一.数字转为 string 类型 借用 sprintf 函数: char buffer[256]; int counter = 10; sprintf(buffer,"%04i", ...
- hdu 1978 记忆化搜索
注意: dp[i][j] 表示(i,j)这个点有多少种方式 mark[i][j]表示这个点是否走过 假设有直接返回dp[i][j] dp的求法为全部梦走到点的dp的和 注意mark ...
- POJ 3207 Ikki's Story IV - Panda's Trick(2-sat)
POJ 3207 Ikki's Story IV - Panda's Trick id=3207" target="_blank" style=""& ...
- C++ double转string类型以及MFC控件简单使用方法
这两天项目须要,測试c++库里面内容.生成jar再给Android调用.我没有学过C++,如今開始记录C++简单使用方法.測试时候一般都是使用mfc程序来測试.要输入值.显示结果吗.我用的编译环境vs ...
- Java JNI 入门篇——传递数组与修改数组
这里不在重复JavaJNI 的开发过程了,不熟悉的同学请参考:Java JNI HelloWorld 直接上主要代码: ArrayJNI.Java package com.example.jni; p ...
- AvtiveMQ 参考
推荐学习:https://www.cnblogs.com/zhuxiaojie/p/5564187.html#autoid-2-1-0
- POJ 3187 全排列+杨辉三角(组合数)
思路: next_permutation()加个递推组合数随便搞搞就A了- //By SiriusRen #include <cstdio> #include <algorithm& ...