Advanced 1008 Elevator

PAT题目链接

#include 
int main() {
    int curr,next,num,ans;
    while (scanf("%d", &num) != EOF) {
        next=0;
        ans=0;
        for(int i=0;i curr) {
                ans += (next - curr) * 6 + 5;
            } else if (next < curr) {
                ans += (curr - next) * 4 + 5;
            } else {
                ans += 5;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

你可能感兴趣的:(Advanced 1008 Elevator)