package com.ctgu.java.exer; public class Test { public static void main(String[] args) { int i,sum = 0,n=100; for(i=1; i<=n ; i++){ sum += i ; } System.out.println(sum); sum =(1 + n)*n/2; System.out.println(sum); // TODO Auto-generated method stub } }
原文地址:http://9815936.blog.51cto.com/9805936/1601466