Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

附上精简点的代码供参考

Posted by Veegin at 2011-04-27 09:39:21 on Problem 3299
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator