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

Re:我的代码是这样的,为什么。。。。

Posted by Cunch at 2009-08-16 20:15:55 on Problem 3299
In Reply To:我的代码是这样的,为什么。。。。 Posted by:LittleCarol at 2009-07-03 15:33:56
> #include <stdio.h>
> #include <math.h>
> 
> int main()
> {
> 	float humidex, temperature, dewpoint;
> 	float h, e;
> 
> 	char c1, c2;
> 	float tmp1, tmp2;
> 	while(scanf("%c", &c1), c1!='E')
> 	{
> 	
> 		scanf("%f %c %f", &tmp1, &c2, &tmp2);
> 		switch(c1+c2)
> 		{
> 		case 'T'+'D':
> 			temperature = (c1 == 'T')?tmp1:tmp2;
> 			dewpoint = (c1 == 'D')?tmp1:tmp2;
> 			e = (float)(6.11 * exp(5417.753 * ((1/273.16) - (1/(dewpoint + 273.16)))));
> 			h = (float)(0.5555 * (e - 10.0));
> 			humidex = temperature + h;
> 			break;
> 		case 'T'+'H':
> 			temperature = (c1 == 'T')?tmp1:tmp2;
> 			humidex = (c1 == 'H')?tmp1:tmp2;
> 			h = (humidex - temperature);
> 			e = (float)(h/0.5555 + 10.0);
> 			dewpoint = 1/((1/273.16) - (log(e/6.11))/5417.753) - 273.16;
> 			break;
> 		case 'H'+'D':
> 			humidex = (c1 == 'H')?tmp1:tmp2;
> 			dewpoint = (c1 == 'D')?tmp1:tmp2;
> 			e = (float)(6.11 * exp(5417.753 * ((1/273.16) - (1/(dewpoint + 273.16)))));
> 			h = (float)(0.5555 * (e - 10.0));
> 			temperature = humidex - h;
> 			break;
> 		default:
> 			break;
> 
> 		}
> 		printf("T %.1f D %.1f H %.1f\n", temperature, dewpoint, humidex);
> 		scanf("%c", &c1);//为什么一定要加这一句呢?这里才c1得到的是一个回车符
> 	
> 	}
> 	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