Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
很简单,就是推公式的时候别推错了。用来调节心情比较好使。#include <iostream> #include <cmath> using namespace std; int main() { char ch1,ch2; double temperature, dewpoint, humidex; while(cin >> ch1 && ch1!='E') { switch(ch1) { case 'T': cin >> temperature; break; case 'D': cin >> dewpoint; break; case 'H': cin >> humidex; break; default: break; } cin >> ch2; switch(ch2) { case 'T': cin >> temperature; break; case 'D': cin >> dewpoint; break; case 'H': cin >> humidex; break; default: break; } if((ch1=='T'&&ch2=='D')||(ch1=='D'&&ch2=='T')) { double e = 6.11 * exp (5417.7530 * ((1/273.16) - (1/(dewpoint+273.16)))); double h = (0.5555)*(e - 10.0); humidex = temperature + h; } else if((ch1=='T' &&ch2=='H') ||(ch1=='H' &&ch2=='T')) { double h = humidex - temperature; double e= h/(0.5555)+10.0; dewpoint = 1/(1/273.16-(log(e/6.11))/5417.7530)-273.16; } else if((ch1=='D'&&ch2=='H') || (ch1=='H' && ch2=='D') ) { double e = 6.11 * exp (5417.7530 * ((1/273.16) - (1/(dewpoint+273.16)))); double h = (0.5555)*(e - 10.0); temperature = humidex - h; } printf("T %.1f D %.1f H %.1f\n", temperature, dewpoint, humidex); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator