11智能在线
新记
java求1~100之间所有偶数的个数
要求用循环语句,不用for循环。
举报该文章
相关建议 2009-12-03
public class Test{
public static void main(String[] args){
//计数器
int n = 0;
int x = 100;
while(x > 0){
if(x%2 == 0)n++;
x--;
}
System.out.println("共有个"+n+"偶数");
}
}
温馨提示:内容为网友见解,仅供参考
当前网址:
https://11.t2y.org/zz/fp478qqff.html
其他看法
第1个回答 2009-12-03
public class Test{
public static void main(String[] args){
//个数
int n=0;
//每一个数
int x=1;
while(x<=100){
if(x%2==0)
n=n+1;
x=x+1;
}
System.out.println("共有个"+n+"偶数");
}
}
相似回答
大家正在搜
相关问题
Java编程计算1-100之间所有偶数的和。
java 编程求出1-100之间偶数的和
Java 输出1-100间的偶数
Java编程 求1-100之间的所有偶数
在JAVA中用for循环语句求1到100之间所以偶数的和
用java输出自然数1-100中偶数之和
用JAVA程序 分别求出1--100间的奇数,偶数之和.
Java怎么编程输出1-100间的偶数?