public static void main (String[]arge){ int sum = 0;int num = 2;do { num = (num+2); sum=sum+num; } while ( num<10 ); System.out.println(" 10以内的偶数之和为:" + sum );}
8 回答
已采纳
慕大叔
TA贡献75条经验 获得超103个赞
//你的初始值num=2当然不对 //把num初始值改成num=0 while(num<=10) { num =num+2; sum=sum+num; } System.out.println(" 10以内的偶数之和为:" + sum ); }
添加回答
举报
0/150
提交
取消