关于在线编程做题时的一些规范

转载:http://blog.csdn.net/maoyeqiu/article/details/52062561

1.注意要引入包和输出:

import java.util.Scanner;  
  
public class Main {  
      
    public static int getIntFromDouble(double a){  
        return (int)(a+0.5);  
    }  
      
      
    public static void main(String[] args) {  
        Scanner in = new Scanner(System.in);  
        while(in.hasNextDouble()) {  
            double a = in.nextDouble();  
            System.out.println(getIntFromDouble(a));  
        }  
    }  
}  

 

import java.util.Scanner;  
public class Main {  
    public static void main(String[] args) {  
        Scanner in = new Scanner(System.in);  
        while (in.hasNextInt()) {//注意while处理多个case  
            int a = in.nextInt();  
            int b = in.nextInt();  
            System.out.println(a + b);  
        }  
    }  
}  

 

posted @ 2017-07-16 21:27  lzycw  阅读(188)  评论(0)    收藏  举报