1057.cpp

来自「这是哈尔滨工业大学acmOJ的源代码」· C++ 代码 · 共 47 行

CPP
47
字号
/*  This Code is Submitted by wywcgs for Problem 1057 on 2005-03-11 at 23:09:02 */ 
#include <stdio.h>

int main()
{
    int total, mileage, i;
    char type, ch[20];
    
    while(1){
        total = 0;
        for(i = 0; i < 20; i++){
            ch[i] = '\0';
        }
        while(scanf("%s", ch) == 1){
            if(ch[0] == '0'){
                break;
            }else if(ch[0] == '#'){
                return 0;
            }    
            scanf("%*s %d %c", &mileage, &type);
            switch(type){
                case 'F':
                    total += mileage * 2;
                    break;
                case 'B':
                    if(mileage % 2 == 0){
                        total += mileage * 3 / 2;
                    }else{
                        total += (mileage+1) * 3 / 2 - 1;
                    }
                    break;
                case 'Y' :
                    if(mileage <= 500){
                        total += 500;
                    }else{
                        total += mileage;
                    }
                    break;
                default :
                    break;
            }
        }
        printf("%d\n", total);
    }

    return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?