poj3299

Humidex

#include “iostream” #include “math.h” using namespace std; void formula(double& t,double& d,double& h); int main(int argc, _TCHAR* argv[]) { char cmd; cin>>cmd; while(cmd!=’E’) { double t=200,d=200,h=200; if(cmd==’T’)cin>>t; else if(cmd==’D’)cin>>d; else cin>>h; cin>>cmd; if(cmd==’T’)cin>>t; else if(cmd==’D’)cin>>d; else cin>>h; formula(t,d,h); printf(“T %.1f D %.1f H %.1f/n”,t,d,h); cin>>cmd; } return 0; } void formula(double& t,double& d,double& h) { double e; if(t==200) { e = 6.11 * exp(5417.7530 * ((1/273.16) – (1/(d+273.16)))); t=h-(0.5555)*(e-10.0); } else if(d==200) { e =(h-t)/(0.5555)+10.0; d=(1/((1/273.16)-(log(e/6.11))/5417.7530))-273.16; } else if(h==200) { e = 6.11 * exp (5417.7530 * ((1/273.16) – (1/(d+273.16)))); h=t+(0.5555)* (e – 10.0); } }

点赞