while and do while

package study5ran2yl.study;

public class deno14 {
    public static void main(String[] args) {
        //计算1+2+...+100
        int x = 1;
        int sum = 0;
        while(x<=100)
        {

            sum+=x;
            x++;
        }
        System.out.println(sum);
    }
}

  

 

posted @ 2022-04-26 12:46  回忆也交给时间  阅读(10)  评论(0编辑  收藏  举报