public?class?HelloWorld?{
????public?static?void?main(String[]?args)?{
????????
????????//?變量保存成績
????????int?score?=?53;?
????????
????????//?變量保存加分次數(shù)
????????int?count?=?0;
????????System.out.println("加分前成績:"+?score);
????????//打印輸出加分前成績?
????????if(score?<?60?){
????????for?(int?i?=?1;?i?<=?7;?i++)???{
????????
????????//?只要成績小于60,就循環(huán)執(zhí)行加分操作,并統(tǒng)計加分次數(shù)
????
????????if?(score?==?60?){
????????break;
????????}
????????count?=?i++;
????????score?+=?1?;//這里不太懂,雖然結(jié)果輸出正確了.
????????}
????????System.out.println("加分后成績:"?+?score);
????????
????????System.out.println("共加了"?+?count?+?"次");
????????//打印輸出加分后成績,以及加分次數(shù)
????????}
????????
????}
}
2015-03-19
score+=1;相當于score=score+1;每次循環(huán)加1分,循環(huán)7次加7分,從53加到60;當score=60時,退出循環(huán)。