這個(gè)for循環(huán)為什么錯(cuò)了
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
for(;num>=1;num/10)
? ? count++;
System.out.println("它是個(gè)"+count+"位的數(shù)!");
? ? }
}
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
for(;num>=1;num/10)
? ? count++;
System.out.println("它是個(gè)"+count+"位的數(shù)!");
? ? }
}
2019-06-24
舉報(bào)
2019-07-04
如果用for循環(huán)如下:
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("它是個(gè)"+count+"位的數(shù)!");
? ? }
}
2019-06-24
只需要做個(gè)小小的改動(dòng),在/后面加個(gè)=號(hào)即可