題目:
代碼:
import java.util.Scanner;
public class Jump {
public static void main(String[] args) {
int status = 1;
int score = 0;
int centerCount = 0;
Scanner scan = new Scanner(System.in);
while(true) {
status = scan.nextInt();
if(status == 1) {
score+=1;
centerCount=0;
}
else if(status ==2) {
centerCount+=1;
score+=(centerCount*2);
}
else
break;
}
System.out.println(score);
}
}
主類名稱改為Main