求教錯在哪里?
public class HelloWorld {
? ? public static void main(String[] args) {
? ? ? ? int score = 53;?
? ? ? ? int i = 1;
? ? ? ? int count = 0;
? ? ? ? System.out.println("加分前成績:" + score);
? ? ?
? ? ? ? while(score <= 60){
? ? ? ? count += score;
? ? ? ? ? ? i = i++;
? ? ? ? }?
? ? ? ? System.out.println("加分后成績:" + count);
? ? ? ? System.out.println("共加了" +i+ "次");
? ? }
}
2016-01-10
改成這樣。
你的代碼
2016-01-10
你while循環(huán)里面的score的值沒有改變,所以score一直小于60,死循環(huán)了
2016-01-10
count+=score,不就變成了count=count+score,第一次count=0+53,i=2第二次就是count=53+53,1=3,然后跳出循環(huán)嗎。如果你這代碼意思是要一次加1分加到60分,然后計算加了多少次,應該是這樣的吧