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\),并没有指定 ...
随机推荐
- angular7升级到angular8
1.首先我们对:angular的命令的安装 ng install -g @angular/cli的安装则会升级到最新的版本,并且再次创建项目的时候,我们就能够使用ng version查看到已经是最新的 ...
- BZOJ 3790 神奇项链(manacher+贪心)
3790: 神奇项链 Time Limit: 10 Sec Memory Limit: 64 MB Description 母亲节就要到了,小 H 准备送给她一个特殊的项链.这个项链可以看作一个用小 ...
- redis做成windows服务
打开cmd切换到redis根目录 执行安装命令 redis-server.exe --service-install redis.windows.conf --loglevel verbose 卸载 ...
- 安装anaconda和tensorflow
一.首先下载anaconda,下载:Anaconda2-4.3.1-Linux-x86_64.sh(https://repo.continuum.io/archive/)参考网址:https://ww ...
- 越努力越幸运--3-日常bug修复
提供一个so给PYTHON调用,后端发现业务处理流程不是按照方法传入的参数来跑. 查看c的代码,看了客户端没看出什么问题,查看服务端为什么会出现这样的情况,有些字段明显不是入参带过来的,跟踪服务端解析 ...
- Centos6.6 系统优化
1:最小化安装 2:修改网卡 vim /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0HWADDR=52:54:00:0e:c2:c3TYPE ...
- javaweb实现教师和教室管理系统 java jsp sqlserver
1,程序设计思想 (1)设计三个类,分别是工具类(用来写连接数据库的方法和异常类的方法).信息类(用来写存储信息的方法).实现类(用来写各种操作数据库的方法) (2)定义两个jsp文件,一个用来写入数 ...
- Python格式化字符串、占位符、合并数组
合并数组 参考链接:https://www.cnblogs.com/chaihy/p/7243143.html >>> a=[2] >>> b=[3] >&g ...
- 2015 Multi-University Training Contest 2 Friends
Friends Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Sub ...
- Raw-OS源代码分析之任务删除与总结
分析的内核版本号截止到2014-04-15,基于1.05正式版,blogs会及时跟进最新版本号的内核开发进度,若源代码凝视出现"???"字样,则是未深究理解部分. Raw-OS官方 ...