CCF-跳一跳(201803-1)-C语言(100分)

在这里插入图片描述在这里插入图片描述

#include <stdio.h>

int main(){
    int n,score=0,step=1;
    scanf("%d",&n);
    while(n!=0){
        if(n==1){
            score+=1;
            step=1;
        }
        else{
            score+=step*2;
            step++;
        }
        scanf("%d",&n);
    }
    printf("%d\n",score);
    return 0;
}
发布了33 篇原创文章 · 获赞 11 · 访问量 8461

猜你喜欢

转载自blog.csdn.net/qq_40825479/article/details/105529270
今日推荐