博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Humidex C语言 POJ3299
阅读量:5345 次
发布时间:2019-06-15

本文共 4209 字,大约阅读时间需要 14 分钟。

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 15T 30.0 D 25.0E

Sample Output

T 30.0 D 15.0 H 34.0T 30.0 D 25.0 H 42.3

我认为难点在于由温度和湿度求露点,我使用的是书上看到的减半递推法,设露点的初始值为0,露点的增量从100,然后使用一个循环,由温度当前假设的露点值计算湿度,如果大于,则露点值减少一个增量,否则增加一个增量,每次计算后增量减半,直到增量小于等于0.0001

1 #include 
2 #include
3 #include
4 double e,h; 5 double wd,sd,ld; 6 7 void jse(double A){
//计算e 8 e=6.11*exp(5417.7530*((1/273.16)-(1/(A+273.16)))); 9 }10 11 void jsh(){
//计算h12 h=(0.5555)*(e-10.0);13 }14 15 double jssd(double b){
//计算湿度,b为露点 16 double s;17 jse(b);18 jsh();19 s=wd+h;20 return s;21 }22 23 void jswd(){
//计算温度24 jse(ld);25 jsh();26 wd=sd-h;27 } 28 29 void jsld(){
//计算露点,湿度,温度已知 30 double i=100,sd1=sd;31 for(ld=0;i>0.00001;i*=0.5){32 if(jssd(ld)>sd) ld-=i;33 else ld+=i;34 }35 }36 37 int main(void){38 double m,n;39 char a,b;40 while(scanf("%c %lf %c %lf",&a,&m,&b,&n)==4){41 wd=sd=ld=-101;42 if(a=='T') wd=m;43 else if(a=='H') sd=m;44 else ld=m;45 if(b=='T') wd=n;46 else if(b=='H') sd=n;47 else ld=n;48 if(wd==-101) jswd();49 else if(sd==-101) sd=jssd(ld);50 else jsld();51 printf("T %.1f D %.1f H %.1f\n",wd,ld,sd);52 scanf("%c",&a);53 }54 return 0;55 }
View Code

 

转载于:https://www.cnblogs.com/20174317zhuyuan/p/9388113.html

你可能感兴趣的文章
NEYC 2017 游记
查看>>
[搬运] 写给 C# 开发人员的函数式编程
查看>>
Python之旅Day14 JQuery部分
查看>>
core--线程池
查看>>
redux-effect
查看>>
Android轻量级的开源缓存框架ASimpleCache
查看>>
他山之石:加载图片的一个小问题
查看>>
shell - 常识
查看>>
mssql sqlserver 使用sql脚本 清空所有数据库表数据的方法分享
查看>>
分层图最短路【bzoj2763】: [JLOI2011]飞行路线
查看>>
linux下编译复数类型引发的错误:expected unqualified-id before '(' token
查看>>
codeforces 1041A Heist
查看>>
Spring Cloud Stream消费失败后的处理策略(三):使用DLQ队列(RabbitMQ)
查看>>
bzoj1048 [HAOI2007]分割矩阵
查看>>
Java中的编码
查看>>
PKUWC2018 5/6
查看>>
As-If-Serial 理解
查看>>
洛谷P1005 矩阵取数游戏
查看>>
在Silverlight中使用HierarchicalDataTemplate为TreeView实现递归树状结构
查看>>
无线通信基础(一):无线网络演进
查看>>