您好,现在瑶瑶来为大家解答以上的问题。while循环输出1到100的整数,请运用while循环结构输出1 100中所有的奇数相信很多小伙伴还不知道,现在让我们一起来看看吧!

1、以下为参考代码:public class Example13 {    public static void main(String[] args) {        int x = 1;        int count = 0;        while (x <= 10) {            if (x % 2 != 0) {                count++;            }            x++;        }        System.out.println("奇数的个数有:" + count);    }}以下为控制台:。

本文就为大家分享到这里,希望小伙伴们会喜欢。