我想知道FOR后面有()了后面加這個{}什么意思,加這個之后COUNT就會因為SCORE到60之后會停止了么?我錯哪兒了?為什么不能運(yùn)行
??????? int score = 53;
??????? int count = 0;
??????? System.out.println("加分前的成績:"+score);
????????? for(score<60;score++){
????????????? count++;
????????? }
????????? System.out.println("加分后成績:"+score);
????????? System.out.println("共加了"+count+"次!");
?????????
2018-11-21
后面{}里面是寫滿足for()里的條件后所要執(zhí)行的循環(huán)語句,你這個for()里面判斷語句是指條件滿足score小于60的話,執(zhí)行count自增1語句,然后再返回上面條件同時讓score自增1,你這個是在for()里面邊少了個;號,即使沒有聲明變量,;號也不能省下,正確的是:
int score = 53;
??????? int count = 0;
??????? System.out.println("加分前的成績:"+score);
????????? for(;score<60;score++){
????????????? count++;
????????? }
????????? System.out.println("加分后成績:"+score);
????????? System.out.println("共加了"+count+"次!");