You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
286 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

public class Jb11_WhileTest
{
public static void main(String[] args)
{
//输出1到100之间里2的倍数有几个。计数器思想
int x = 1;
int count = 0;
while (x<=100)
{
if (x%2==0)
{
count++;
}
x++;
}
System.out.println("1~100之间2的倍数个数总共是"+count);
}
}