101-102+103-104+105-106+.....+199-200+100在java中怎么实现
101-102+103-104+105-106+.....+199-200+100在java中怎么实现
日期:2016-03-27 09:51:51 人气:1
public class Test { public static void main(String[] args) { int sum = 0; for(int i = 101; i <=200;i++){ if(i % 2 == 0){ sum -= i; }else { sum += i; } } System.out.println("结果:" + (sum+100)); }}