题目:http://acm.hdu.edu.cn/showproblem.php?pid=1001
import java.util.Scanner;public class Main{public static void main(String[] args) {Scanner cin= new Scanner(System.in);int sum;while(cin.hasNextInt()){sum=cin.nextInt();if((sum%2)==0)System.out.println(sum/2*(sum+1));elseSystem.out.println((sum+1)/2*sum);System.out.println();}cin.close();//关闭输入流,关闭所有。}
}