CCF模拟试题 201803-1 跳一跳 JAVA

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        int[] in = new int[2];
        int  score=0;
        in[1] = 0;

        in[0] = s.nextInt();
        while (in[0]!=0){
            if(in[0]==1){
                in[1] = 0;
                score += 1;
            }else{
                in[1] +=1;
                score = score + 2 * in[1];
            }
            in[0] = s.nextInt();
        }

        System.out.printf("%d",score);
    }
}

你可能感兴趣的:(CCFCSP)