public class Total{ public static void main(String[] args){
int total = 0; for(int num = 2; num <= 100;num = num*2){ total += num; } System.out.println("100以内的偶数和为:"+total);}
}
本文共 227 字,大约阅读时间需要 1 分钟。
public class Total{ public static void main(String[] args){
int total = 0; for(int num = 2; num <= 100;num = num*2){ total += num; } System.out.println("100以内的偶数和为:"+total);}
}
转载于:https://my.oschina.net/u/1388978/blog/176243