poj3299

Source Code

Problem: 3299   User: mtawaken
Memory: 200K   Time: 0MS
Language: C++   Result: Accepted
  • Source Code

  • #include <cstdio>
    #include <math.h>
    
    char c1,c2;
    double f1,f2;
    char tag[]={'T','D','H'};
    
    double res[3];
    
    double dew2h(double dewpoint){
    	double e = 6.11*exp(5417.7530*((1/273.16)-(1/(dewpoint+273.16))));
    	return (0.5555)*(e-10.0);
    }
    double h2dew(double h){
    	double e = (h/0.5555)+10.0;
    	return 1/((1/273.16)-((log(e/6.11))/5417.7530))-273.16;
    }
    bool readIn(){
    	scanf("%c",&c1);
    	if(c1=='E')return false;
    	return scanf("%lf %c%lf",&f1,&c2,&f2)==3;
    }
    
    int main(){
    	while(readIn()){	
    		res[0]=res[1]=res[2]=102.0;
    		for(int i=0;i<3;i++){
    			if(tag[i]==c1)res[i]=f1;
    			if(tag[i]==c2)res[i]=f2;
    		}
    		if(res[0]>101.0){
    			double h = dew2h(res[1]);
    			res[0] = res[2] - h;
    		}else if(res[1]>101.0){
    			double h = res[2] - res[0];
    			res[1] = h2dew(h);
    		}else{
    			double h = dew2h(res[1]);
    			res[2] = res[0] + h;
    		}
    		for(int i=0;i<3;i++){
    			printf("%c %.1f ",tag[i],res[i]);			
    		}
    		printf("\n");
    		getchar();
    	}
    }


你可能感兴趣的:(poj3299)