| ||||||||||
| 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 <stdio.h>
#include <math.h>
#include <string.h>
int main()
{
double h,t,d,v[2],ans;// h为humidex,t为temperature,d为dewpoint
int i,visited[3],flag;
char ch[2];
while(scanf("%c",&ch[0])!=EOF&&ch[0]!='E')
{
memset(visited,0,sizeof(visited));
scanf("%lf %c %lf",&v[0],&ch[1],&v[1]);
getchar();
for(i=0;i<2;i++)
{
if(ch[i]=='T') t=v[i],visited[0]=1;
else if(ch[i]=='D') d=v[i],visited[1]=1;
else h=v[i],visited[2]=1;
}
for(i=0;i<3;i++) {if(!visited[i]) flag=i;}
switch(flag)
{
case 0: t=h-0.5555*(6.11*exp(5417.7530*(1/273.16-1/(d+273.16)))-10.0); break;
case 1: d=1/(1/273.16-log(((h-t)/0.5555+10)/6.11)/5417.753)-273.16; break;
case 2: h=t+0.5555*(6.11*exp(5417.7530*(1/273.16-1/(d+273.16)))-10.0);
}
printf("T %.1f D %.1f H %.1f\n",t,d,h);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator