poj 3299 java

今天尝试一下poj平台 略有点忐忑 不知道自己能不能搞定。

上网查了一下poj题目推荐,所以从poj 3299题开始练手。

后来发现试了好几次都不成功,弄得我好郁闷,所以往1000这个sample里看看是什么出错,发现公共类public class 后面不应该写 “Humidex”而是要写"Main"。

初心者的才会犯的尴尬事情。

其次是自己编写的会造成 Presentation Error , 是因为输出结果格式不正确,后来略微调整一下就ok了。

 

记住一篇文章,是《 POJ推荐50题以及ACM训练方案》 ,稍后转载,毕竟是前人经验,就跟着试试。

其次呢,是一个网址,《JAVA解北大ACM POJ源码》,http://www.java3z.com/cwbwebhome/article/article17/POJ3.html

可以多多参考。

接下来是看了例题之后自己试着敲出的3299,试运行成功。

 1 import java.io.BufferedInputStream;
 2 import java.util.Scanner;
 3 
 4 
 5 public class Main{
 6     public static void main(String args[]){
 7         
 8         double e = 2.718281828;
 9         String alpha;
10         
11         Scanner cin = new Scanner(new BufferedInputStream(System.in));
12         
13         
14         while(cin.hasNext()){
15             
16             double t=102,d=102,h=102;
17             
18             for(int i =0; i<2;i++){
19                 alpha = cin.next();
20                 
21                 if(alpha.equals("H")){
22                     h=cin.nextDouble();
23                 }else if(alpha.equals("D")){
24                     d=cin.nextDouble();
25                 }else if (alpha.equals("T")) {
26                     t=cin.nextDouble();
27                 }else if (alpha.equals("E")) {
28                     System.exit(0);
29                     
30                 }
31             }
32             
33             double e2 = 6.11*Math.pow(e, 5417.7530 * ((1/273.16) - (1/(d+273.16))));
34             
35             if(h==102){
36                 h=t+0.5555*(e2-10.0);
37                 System.out.print("T ");   
38                 System.out.printf("%.1f", t);   
39                 System.out.print(" D ");   
40                 System.out.printf("%.1f", d);   
41                 System.out.print(" H ");   
42                 System.out.printf("%.1f", h);   
43                 System.out.println(); 
44             }
45             if(t==102){
46                 t=h-0.5555*(e2-10.0);
47                 System.out.print("T ");   
48                 System.out.printf("%.1f", t);   
49                 System.out.print(" D ");   
50                 System.out.printf("%.1f", d);   
51                 System.out.print(" H ");   
52                 System.out.printf("%.1f", h);   
53                 System.out.println();
54             }
55             if(d==102){
56                 e2=(h-t)/0.5555+10.0;
57                 d=1/((1/273.16)-Math.log(e2/6.11)/5417.7530)-273.16;
58                 d=(double)Math.round(d*10)/10;
59                 System.out.print("T ");   
60                 System.out.printf("%.1f", t);   
61                 System.out.print(" D ");   
62                 System.out.printf("%.1f", d);   
63                 System.out.print(" H ");   
64                 System.out.printf("%.1f", h);   
65                 System.out.println();
66                 
67             }
68 
69             
70         }
71     
72     }
73 }
View Code

好了,多多练习,加油,小星星~

posted @ 2013-08-06 17:36  逢尘化雪  阅读(602)  评论(0编辑  收藏  举报