Java 实例 - 数字求和运算

Java 教程 · 2019-02-11 11:42:45

以下实例演示了使用do...while结构求0~100的整数数字之和:

Main.java 文件

public class Main { public static void main(String[] args) { int limit=100; int sum=0; int i=1; do { sum=sum+i; i++; } while(i<=limit); System.out.println("sum="+sum); } }

以上代码运行输出结果为:

sum=5050

点击查看所有 Java 教程 文章: https://www.codercto.com/courses/l/12.html

查看所有标签

Introduction to the Design and Analysis of Algorithms

Introduction to the Design and Analysis of Algorithms

Anany Levitin / Addison Wesley / 2011-10-10 / USD 117.00

Based on a new classification of algorithm design techniques and a clear delineation of analysis methods, Introduction to the Design and Analysis of Algorithms presents the subject in a coherent a......一起来看看 《Introduction to the Design and Analysis of Algorithms》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码