這個(gè)代碼有什么錯(cuò)誤嗎
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
for(num<=99999999;count++){
? ? if(num%count==3)
}
System.out.println(他是個(gè)"+count"位數(shù))
}
}
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
for(num<=99999999;count++){
? ? if(num%count==3)
}
System.out.println(他是個(gè)"+count"位數(shù))
}
}
2019-03-19
舉報(bào)
2019-03-24
希望一下對(duì)你有所幫助:
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
for(num<=99999999;count++){//這里的for語(yǔ)句存在語(yǔ)法錯(cuò)誤,可以寫成for(;num<=99999999;count++)
? ? if(num%count==3)//這里缺少你進(jìn)行if判斷后執(zhí)行的語(yǔ)句
}
System.out.println(他是個(gè)"+count"位數(shù))//需要添加一個(gè)分號(hào)“;”
}
}
2019-03-19
這不是全是錯(cuò)誤嗎。。
2019-03-19
for(;num<=99999999;count++){ //少了個(gè)分號(hào)
? ? if(num%count==3)? ?// 你想算什么?余數(shù)嗎?如果是的話,,,count=0時(shí)會(huì)出錯(cuò)
????? ? ?//if后面得寫一句話,比如num++;或者不想寫就寫個(gè){}
System.out.println("他是個(gè)"+count+"位數(shù)");//少了個(gè)加號(hào),兩個(gè)引號(hào),一個(gè)分號(hào)。
錯(cuò)誤挺多的,。。你得好好熟悉熟悉