哪里錯了啊
public class HelloWorld {
? ? public static void main(String[] args) {
? ? ? ??
? ? ? ? // 變量保存成績
? ? ? ? int score = 53;?
? ? ? ??
? ? ? ? // 變量保存加分次數
? ? ? ? int count = 0;
? ? ? ? System.out.println("加分前分數"+score);
? ? ? for(int score=53;score<60;score++){count++;
? ? ? ? ?
? ? ? }
? ? ? System.out.println("加分后分數"+score);
? ? ? System.out.println("次數"+count);
? ? ? ? //打印輸出加分前成績?
? ? }
2020-05-18
score變量是main方法的局部變量 ,作用域是從定義到程序結束,所以并不需要在for循環中再次定義它的類型;
2020-05-12
把for循環里的變量取出來
2020-05-10
? ? ? ? int score = 53;
? ? ? ? // 變量保存成績? ? ??
? ? ? ? int count=0;
? ? ? ? // 變量保存加分次數
? ? ? ? System.out.println("加分前分數"+score);
? ? ? for(;score<60;score++){
? ? ? if(score>=100) {
? ? ? score++;
? ? ? }? ? ?count++;
? ? ? }
? ? ? System.out.println("共加了" + count + "次");
? ? System.out.println("加分后成績"+ score);
??
? ? ? ? //打印輸出加分前成績?
? ? }
? ? }
2020-05-09
for 里面已經定義過了 score ,不需要int 了