杭电ACM1001

不再更新,杭电ACM的题转到csdn博客

import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);    
        int a;
        while(scan.hasNextInt()){
            a=scan.nextInt();
            System.out.println(sum(a));
            System.out.println();
        }
    }
    
    static int sum(int a){
        int sum=0;
        for(int i=1;i<=a;i++){
            sum+=i;
        }
        return sum;
    }

}

你可能感兴趣的:(杭电ACM1001)