B2046 题解

· · 题解

先读入一个字母 a ,则骑车所用的时间为: a/3.0+27.0+23.0 ,走路的时间为: a/1.2

把结果存入两个变量里,最后比较:

#include<bits/stdc++.h>
using namespace std;
int a;double b,c;
int main()
{      
    cin>>a;
    b=a/1.2;
    c=a/3.0+27.0+23.0;
    if(c>b)
        cout<<"Walk";
    else if(b>c)
        cout<<"Bike";
    else
        cout<<"All";
        return 0;
}