poj 1326 Mileage Bank

poj 1326 Mileage Bank,第1张

poj 1326 Mileage Bank
#include <iostream>#include <cstdlib>#include <cstdio>#include <cstring>using namespace std;#define maxl 105int ans;int cal(char ch, int d){    if (ch == 'Y')        return max(500, d);    if (ch == 'B')        return int(1.5 * d + 0.5);    return 2 * d;}void input(){    char name1[maxl], name2[maxl], type[maxl];    int dist;    while (true)    {        scanf("%s", name1);        if (strcmp(name1, "0") == 0) return;        if (strcmp(name1, "#") == 0) exit(0);        scanf("%s%d%s", name2, &dist, type);        ans += cal(type[0], dist);    }}int main(){    while (1)    {        ans = 0;        input();        printf("%dn", ans);    }    return 0;}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4925758.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-12
下一篇 2022-11-12

发表评论

登录后才能评论

评论列表(0条)

保存