為啥輸出共加了60次
public class HelloWorld {
? ? public static void main(String[] args) {
? ? ? ??
? ? ? ? // 變量保存成績
? ? ? ? int score = 53;?
? ? ? ??
? ? ? ? // 變量保存加分次數(shù)
? ? ? ? int count = 0;
? ? ? ? //打印輸出加分前成績?
? ? ??
? ? ? ?System.out.println("加分前成績:"+score);
? ? ? ??
? ? ? ? // 只要成績小于60,就循環(huán)執(zhí)行加分操作,并統(tǒng)計加分次數(shù)
? ? ? ? ? for(;score<60;score++){
? ? ? ? ? ? ?count++;
? ? ? ? ? }
? ? ? ? ? System.out.println("加分后成績:"+score);
? ? ? ? ? System.out.println("共加了"+score+"次");
2022-04-24
for 循環(huán)前面是空
2022-04-14
?System.out.println("共加了"+score+"次");? ?//? 中間的score應(yīng)該改為count,你寫的score代表的是分數(shù)而不是加的次數(shù)。
搜索
復(fù)制
2022-04-13
System.out.println("共加了"+score+"次");
第三句輸出誰讓你輸出score了,換成count
System.out.println("共加了"+count+"次");