安全问答

安全问答是一个知识全球问答,包含丰富的问答知识

首页 常规 游戏 娱乐 科技 程序员

用Java语言编写1+1+2+1+2+3+100的结果

  • 日期: 2027-10-17
  • 标签: 教育
public class Main {
    public static void main(String[] args) {
        int sum = 0;
        int currentNumber = 1;
        
        for (int i = 1; i <= 100; i++) {
            sum += currentNumber;
            currentNumber++;
            if (currentNumber > i) {
                currentNumber = 1;
            }
        }
        
        System.out.println("结果为:" + sum);
    }
}
用Java语言编写1+1+2+1+2+3+100的结果

原文地址: https://www.cveoy.top/t/topic/hOTI 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录

  • 上一篇: 计算引擎是干嘛的举一个具体的列子
  • 下一篇: 从幼儿成长角度写200字英文具体的描述性小记内容Olivia在自由活动时间越来越具有领导和指挥的表现她会告诉小朋友她想怎么玩并且按照她的方式小朋友也会和她讨论继续加油。今天我们做了水果酸奶豆豆很认真的加了酸奶和水果。

© 2019 • 2025 - 安全问答 站长邮箱:wxgpt@qq.com    ICP备案/许可证号:豫ICP备2024104334号-2