public static void main(String[] args) { int sum = 0; for (int i = 2; i < 100; i += 2) { sum += i; } System.out.println("1到100(不含100)间所有偶数的和:" + sum); }
int sum = 0;int n = 2;while (n <= 100) { sum += n; n += 2;}