求大神指点下这个算法结果为啥不对?结果为62
public class dp {
public static void main(String[] args){
int num = 2;
do {
//实现累加求和
num+=num;
num = num + 2;
} while (num<=50);
System.out.println(" 50以内的偶数之和为:" + num );
}
}
public class dp {
public static void main(String[] args){
int num = 2;
do {
//实现累加求和
num+=num;
num = num + 2;
} while (num<=50);
System.out.println(" 50以内的偶数之和为:" + num );
}
}
2015-08-22
举报