雖然運(yùn)行正確,但是我總感覺(jué)有問(wèn)題,各位同學(xué)幫忙看看可以嗎~
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
for(;count<10; count++){
? ? if(num/10==0)
? ? {
? ? ? ? System.out.println("它是個(gè)"+(count+1)+"位的數(shù)!");
? ? ? ? break;
? ? }
? ? num = num/10;
}
}
}
2019-05-26
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
for(;count<10; count++){
? ? if(num==0)
? ? {
? ? ? ? System.out.println("它是個(gè)"+(count)+"位的數(shù)!");
? ? ? ? break;
? ? }
? ? num = num/10;
}
}
}
感覺(jué)這樣符號(hào)邏輯,num可能為0
2019-05-26
題目說(shuō)小于10位,那最多檢驗(yàn)9位數(shù)。你的代碼里for循環(huán)里count 變量小于10,那最大就是9,? ? 9+1=10,你的代碼最多可以檢驗(yàn)10位數(shù)。不合題意而已,其他沒(méi)問(wèn)題。0.0,嘻嘻嘻