為啥總是運(yùn)行成功輸出錯誤?試了一下都能成功數(shù)出多少位數(shù)呢?
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count=0;
int j=1;
?for(count=0;count<=10;count++){
??? if(num>=j){
??? j=j*10;
??? continue;
??? }
??? else{
??? System.out.println("它是個"+ count +"位數(shù)");
??? break;
??????? }
??? }
???
2020-07-16
額。。。試了一下你的代碼,確實(shí)這么提示的,可你有沒有認(rèn)真看看他要求輸出的字符串是啥,程序畢竟是死的,你輸出里面少了個“的”字
2020-08-06
public class HelloWorld{
public static void main(String[] args){
? ? int num = 999;
? ? int count=0;
? ? int j=1;
? ??
? ? for(int count=0; count<=10; count++){
? ? ? ? if(num >= j){
? ? ? ? ? ? j = j*10;
? ? ? ? ? ? continue;
? ? ? ? }else{
? ? ? ? ? ? System.out.println("它是個"+ count +"位數(shù)");
? ? ? ? ? ? break;
? ? }
}
看了一會沒看懂你的思慮,只能做個小提醒,for中參數(shù)要又類型,能說說你定義的 j 用來保存什么嗎?