全球播报:编写程序 实现利用while循环输出100以内偶数的功能_请运用while循环结构输出1 100中所有的奇数
发布时间:2023-04-26 20:01:09
来源:互联网
(资料图片仅供参考)
1、以下为参考代码:publicclassExample13{publicstaticvoidmain(String[]args){intx=1;intcount=0;while(x<=10){if(x%2!=0){count++;}x++;}System.out.println("奇数的个数有:"+count);}}以下为控制台:。
本文为大家分享到这里,希望小伙伴们有帮助。