> 其他 >
java语言中利用while语句计算:2+4+…+100的值
人气:303 ℃ 时间:2019-10-23 13:05:09
解答
class Test{
    public static void main(String[] args){
         int sum=0;
         int i=2;
         while(i<=100){
               sum+=i;
               i+=2;
         }
      System.out.print("\nThe result is: "+sum);
     }
  }
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版