我是靠谱客的博主 纯真铃铛,这篇文章主要介绍数字累加,现在分享给大家,希望可以做个参考。

public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int start = sc.nextInt();//开始的累加的数字
        int end = sc.nextInt();//累加结束的数字

        int i = start;
        int sum = 0;//累加的和
        while(i <= end){//循环累加
            sum += start;
            start++;
            i++;
        }
        System.out.println(sum);
        sc.close();
    }

运行结果:
这里写图片描述

最后

以上就是纯真铃铛最近收集整理的关于数字累加的全部内容,更多相关数字累加内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(112)

评论列表共有 0 条评论

立即
投稿
返回
顶部