第五章練習題3

Duanhaifeng55發表於2018-04-02

//求100以內偶數之和

package learn;

public class Cycle {
public static void main(String[] args) {
int sum=0;
int num=2;
while(num<=100) {
//num++;
sum=sum+num;
num=num+2;

}
System.out.println("100以內的偶數之和為:"+sum);}
}