import java.util.Scanner;

public class Main{

public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int num = -1;
    int score = 0;
    int prior = 0;
    //当输入0时  游戏结束  计算分数
    while((num=input.nextInt())!=0){
        if(num==1){
            score = score+1;
            prior = 1;
        }
        else if(num==2){
            if(prior==0||prior==1){
                score = score+2;
                prior = 2;
            }
            else{
                score = score+prior+2;
                prior = prior+2;
            }
        }
    }
    System.out.println(score);
}

}

版权声明:本文为Coeus-P原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/Coeus-P/p/9648488.html