這個for循環為什么錯了
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
for(;num>=1;num/10)
? ? count++;
System.out.println("它是個"+count+"位的數!");
? ? }
}
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
for(;num>=1;num/10)
? ? count++;
System.out.println("它是個"+count+"位的數!");
? ? }
}
2019-06-24
舉報
2019-07-04
如果用for循環如下:
public class HelloWorld{
? ? public static void main(String[] args){
? ? ? ? int num = 999;
? ? ? ? int count = 0;
? ? ? ? for(;;){
? ? ? ? ? ? count++;
? ? ? ? ? ? num = num / 10;
? ? ? ? ? ? if(num == 0)
? ? ? ? ? ? ? ? break;
? ? ? ? }
? ? ? ? System.out.println("它是個"+count+"位的數!");
? ? }
}
2019-06-24
只需要做個小小的改動,在/后面加個=號即可