美文网首页
2018-10-29 1-100求和运算while循环语句使用

2018-10-29 1-100求和运算while循环语句使用

作者: w_water | 来源:发表于2018-10-29 19:31 被阅读0次

package com.neusoft.test;

public class Test2 {

public static void main(String[] args) {

// TODO Auto-generated method stub

//1-100求和运算while语句;

int i=0;

int sum=0;

while(i<=100){

sum=sum+i;

i=i+1;

}

System.out.print("sum=" +sum);

}

}

运行结果:5050

相关文章

网友评论

      本文标题:2018-10-29 1-100求和运算while循环语句使用

      本文链接:https://www.haomeiwen.com/subject/buditqtx.html