我的結果為啥是8次?。。。。?/h1>
public class HelloWorld {
? ?public static void main(String[] args) {
? ? ? ?// 變量保存成績
? ? ? ?int score = 53;
? ? ? ?// 變量保存加分次數
? ? ? ?int count = 0;
? ? ? ?//打印輸出加分前成績
? ? ? ?System.out.println("加分前成績"+score);
? ? ? ?// 只要成績小于60,就循環執行加分操作,并統計加分次數
? ? ? ?for(int i = score; i<=60 ; i++){
? ? ? ? ? ?count+=1;
? ? ? ? ? ?score = i;
? ? ? ?}
? ? ? ?//打印輸出加分后成績,以及加分次數
? ? ? ?System.out.println("加分后成績"+score);
? ? ? ?System.out.println("共加了"+count+"次");
? ?}
}
public class HelloWorld {
? ?public static void main(String[] args) {
? ? ? ?// 變量保存成績
? ? ? ?int score = 53;
? ? ? ?// 變量保存加分次數
? ? ? ?int count = 0;
? ? ? ?//打印輸出加分前成績
? ? ? ?System.out.println("加分前成績"+score);
? ? ? ?// 只要成績小于60,就循環執行加分操作,并統計加分次數
? ? ? ?for(int i = score; i<=60 ; i++){
? ? ? ? ? ?count+=1;
? ? ? ? ? ?score = i;
? ? ? ?}
? ? ? ?//打印輸出加分后成績,以及加分次數
? ? ? ?System.out.println("加分后成績"+score);
? ? ? ?System.out.println("共加了"+count+"次");
? ?}
}
2024-01-27
應該是<60就好了,<=60的時候當你的成績在60時會多執行一次